byte-encoded properties issue fixed

This commit is contained in:
Ubuntu authored and robert committed 2023-06-07 10:13:21 -04:00
1 parent c8f5f85635
commit a0dd3ecd68
3 files changed
+46 -21

No files matched your search

+9 -4
View File
@@ -379,10 +379,12 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *evd, void *fnd) {
size_t pos = 0;
struct mg_mqtt_prop prop;
// note: the server will send the properties sorted by their ID
ASSERT((pos = mg_mqtt_next_prop(mm, &prop, pos)) > 0);
ASSERT(prop.iv == 10 && prop.id == MQTT_PROP_MESSAGE_EXPIRY_INTERVAL);
ASSERT((pos = mg_mqtt_next_prop(mm, &prop, pos)) > 0);
ASSERT(prop.id == MQTT_PROP_PAYLOAD_FORMAT_INDICATOR);
ASSERT((pos = mg_mqtt_next_prop(mm, &prop, pos)) > 0);
ASSERT(prop.id == MQTT_PROP_CONTENT_TYPE);
ASSERT(strncmp(prop.val.ptr, "test_content_val_2", prop.val.len) == 0 &&
@@ -422,6 +424,9 @@ static void construct_props(struct mg_mqtt_prop *props) {
props[3].id = MQTT_PROP_CONTENT_TYPE;
props[3].val = mg_str("test_content_val_2");
props[4].id = MQTT_PROP_PAYLOAD_FORMAT_INDICATOR;
props[4].iv = 1;
}
static void test_mqtt_base(void);
@@ -452,7 +457,7 @@ static void test_mqtt_ver(uint8_t mqtt_version) {
struct mg_str topic = mg_str("x/f12"), data = mg_str("hi");
struct mg_connection *c;
struct mg_mqtt_opts opts;
struct mg_mqtt_prop properties[4];
struct mg_mqtt_prop properties[5];
const char *url = "mqtt://broker.hivemq.com:1883";
int i, retries;
mg_mgr_init(&mgr);
@@ -530,7 +535,7 @@ connect_with_options:
opts.topic = topic, opts.message = data, opts.qos = 1, opts.retain = false;
if (mqtt_version == 5) {
opts.props = properties;
opts.num_props = 4;
opts.num_props = 5;
construct_props(properties);
}
retries = 0; // don't do retries for test speed
@@ -548,7 +553,7 @@ connect_with_options:
opts.topic = topic, opts.message = data, opts.qos = 2, opts.retain = false;
if (mqtt_version == 5) {
opts.props = properties;
opts.num_props = 4;
opts.num_props = 5;
construct_props(properties);
}
retries = 0; // don't do retries for test speed