mirror of
https://github.com/espressif/esp-mqtt.git
synced 2026-06-06 05:14:44 +00:00
Merge branch 'removes_forward_slash_on_topics' into 'master'
fix: Removes forward / from topics in examples and test Closes IDFGH-14696 See merge request espressif/esp-mqtt!264
This commit is contained in:
@@ -87,14 +87,14 @@ I (6015) Pool: Pool: 18 bytes deallocated, 623 total bytes in use
|
||||
I (6015) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=33273
|
||||
I (6025) MQTT_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (6035) MQTT_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos1
|
||||
TOPIC=topic/qos1
|
||||
DATA=data_3
|
||||
I (6315) MQTT_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos1
|
||||
TOPIC=topic/qos1
|
||||
DATA=data_3
|
||||
I (6315) Pool: Pool: 23 bytes deallocated, 623 total bytes in use
|
||||
I (6315) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=14345
|
||||
I (6615) MQTT_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
@@ -54,11 +54,11 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos1", "data_3", 0, 1, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -68,7 +68,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -143,9 +143,9 @@ static void mqtt_app_start(void)
|
||||
esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);
|
||||
/*Let's enqueue a few messages to the outbox to see the allocations*/
|
||||
int msg_id;
|
||||
msg_id = esp_mqtt_client_enqueue(client, "/topic/qos1", "data_3", 0, 1, 0, true);
|
||||
msg_id = esp_mqtt_client_enqueue(client, "topic/qos1", "data_3", 0, 1, 0, true);
|
||||
ESP_LOGI(TAG, "Enqueued msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_enqueue(client, "/topic/qos2", "QoS2 message", 0, 2, 0, true);
|
||||
msg_id = esp_mqtt_client_enqueue(client, "topic/qos2", "QoS2 message", 0, 2, 0, true);
|
||||
ESP_LOGI(TAG, "Enqueued msg_id=%d", msg_id);
|
||||
/* Now we start the client and it's possible to see the memory usage for the operations in the outbox. */
|
||||
esp_mqtt_client_start(client);
|
||||
|
||||
@@ -66,10 +66,10 @@ I (8079) MQTT5_EXAMPLE: key is board, value is esp32
|
||||
I (8079) MQTT5_EXAMPLE: key is u, value is user
|
||||
I (8089) MQTT5_EXAMPLE: key is p, value is password
|
||||
I (8089) MQTT5_EXAMPLE: payload_format_indicator is 1
|
||||
I (8099) MQTT5_EXAMPLE: response_topic is /topic/test/response
|
||||
I (8099) MQTT5_EXAMPLE: response_topic is topic/test/response
|
||||
I (8109) MQTT5_EXAMPLE: correlation_data is 123456
|
||||
I (8109) MQTT5_EXAMPLE: content_type is
|
||||
I (8119) MQTT5_EXAMPLE: TOPIC=/topic/qos1
|
||||
I (8119) MQTT5_EXAMPLE: TOPIC=topic/qos1
|
||||
I (8119) MQTT5_EXAMPLE: DATA=data_3
|
||||
I (8129) mqtt5_client: MQTT_MSG_TYPE_UNSUBACK return code is 0
|
||||
I (8129) MQTT5_EXAMPLE: MQTT_EVENT_UNSUBSCRIBED, msg_id=55594
|
||||
|
||||
@@ -37,7 +37,7 @@ static esp_mqtt5_publish_property_config_t publish_property = {
|
||||
.payload_format_indicator = 1,
|
||||
.message_expiry_interval = 1000,
|
||||
.topic_alias = 0,
|
||||
.response_topic = "/topic/test/response",
|
||||
.response_topic = "topic/test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
};
|
||||
@@ -115,25 +115,25 @@ static void mqtt5_event_handler(void *handler_args, esp_event_base_t base, int32
|
||||
print_user_property(event->property->user_property);
|
||||
esp_mqtt5_client_set_user_property(&publish_property.user_property, user_property_arr, USE_PROPERTY_ARR_SIZE);
|
||||
esp_mqtt5_client_set_publish_property(client, &publish_property);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 1);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos1", "data_3", 0, 1, 1);
|
||||
esp_mqtt5_client_delete_user_property(publish_property.user_property);
|
||||
publish_property.user_property = NULL;
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
esp_mqtt5_client_set_user_property(&subscribe_property.user_property, user_property_arr, USE_PROPERTY_ARR_SIZE);
|
||||
esp_mqtt5_client_set_subscribe_property(client, &subscribe_property);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
esp_mqtt5_client_delete_user_property(subscribe_property.user_property);
|
||||
subscribe_property.user_property = NULL;
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
esp_mqtt5_client_set_user_property(&subscribe1_property.user_property, user_property_arr, USE_PROPERTY_ARR_SIZE);
|
||||
esp_mqtt5_client_set_subscribe_property(client, &subscribe1_property);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 2);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 2);
|
||||
esp_mqtt5_client_delete_user_property(subscribe1_property.user_property);
|
||||
subscribe1_property.user_property = NULL;
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
esp_mqtt5_client_set_user_property(&unsubscribe_property.user_property, user_property_arr, USE_PROPERTY_ARR_SIZE);
|
||||
esp_mqtt5_client_set_unsubscribe_property(client, &unsubscribe_property);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos0");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos0");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
esp_mqtt5_client_delete_user_property(unsubscribe_property.user_property);
|
||||
unsubscribe_property.user_property = NULL;
|
||||
@@ -148,7 +148,7 @@ static void mqtt5_event_handler(void *handler_args, esp_event_base_t base, int32
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, reason code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
print_user_property(event->property->user_property);
|
||||
esp_mqtt5_client_set_publish_property(client, &publish_property);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -210,7 +210,7 @@ static void mqtt5_app_start(void)
|
||||
.will_delay_interval = 10,
|
||||
.payload_format_indicator = true,
|
||||
.message_expiry_interval = 10,
|
||||
.response_topic = "/test/response",
|
||||
.response_topic = "test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
};
|
||||
@@ -220,7 +220,7 @@ static void mqtt5_app_start(void)
|
||||
.network.disable_auto_reconnect = true,
|
||||
.credentials.username = "123",
|
||||
.credentials.authentication.password = "456",
|
||||
.session.last_will.topic = "/topic/will",
|
||||
.session.last_will.topic = "topic/will",
|
||||
.session.last_will.msg = "i will leave",
|
||||
.session.last_will.msg_len = 12,
|
||||
.session.last_will.qos = 1,
|
||||
|
||||
@@ -53,9 +53,9 @@ def test_examples_protocol_mqtt5(dut: Dut) -> None:
|
||||
dut.expect_exact("key is u, value is user")
|
||||
dut.expect_exact("key is p, value is password")
|
||||
dut.expect_exact("payload_format_indicator is 1")
|
||||
dut.expect_exact("response_topic is /topic/test/response")
|
||||
dut.expect_exact("response_topic is topic/test/response")
|
||||
dut.expect_exact("correlation_data is 123456")
|
||||
dut.expect_exact("TOPIC=/topic/qos1")
|
||||
dut.expect_exact("TOPIC=topic/qos1")
|
||||
dut.expect_exact("DATA=data_3")
|
||||
res = dut.expect(r"MQTT_EVENT_UNSUBSCRIBED, msg_id=(\d+)[^\d]")
|
||||
msgid_unsubd = res.group(1).decode("utf8")
|
||||
|
||||
@@ -60,11 +60,10 @@ I (4684) MQTTS_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTTS_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static void send_binary(esp_mqtt_client_handle_t client)
|
||||
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
|
||||
// sending only the configured portion of the partition (if it's less than the partition size)
|
||||
int binary_size = MIN(CONFIG_BROKER_BIN_SIZE_TO_SEND, partition->size);
|
||||
int msg_id = esp_mqtt_client_publish(client, "/topic/binary", binary_address, binary_size, 0, 0);
|
||||
int msg_id = esp_mqtt_client_publish(client, "topic/binary", binary_address, binary_size, 0, 0);
|
||||
ESP_LOGI(TAG, "binary sent with msg_id=%d", msg_id);
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -89,7 +89,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ def on_connect(client, userdata, flags, rc): # type: (mqtt.Client, str, bool, s
|
||||
_ = (userdata, flags)
|
||||
print("Connected with result code " + str(rc))
|
||||
event_client_connected.set()
|
||||
client.subscribe("/topic/qos0")
|
||||
client.subscribe("topic/qos0")
|
||||
|
||||
|
||||
def mqtt_client_task(client): # type: (mqtt.Client) -> None
|
||||
@@ -39,7 +39,7 @@ def on_message(client, userdata, msg): # type: (mqtt.Client, tuple, mqtt.client
|
||||
global message_log
|
||||
global event_client_received_correct
|
||||
global event_client_received_binary
|
||||
if msg.topic == "/topic/binary":
|
||||
if msg.topic == "topic/binary":
|
||||
binary, bin_size = userdata
|
||||
print("Receiving binary from esp and comparing with {}, size {}...".format(binary, bin_size))
|
||||
with open(binary, "rb") as f:
|
||||
@@ -57,9 +57,9 @@ def on_message(client, userdata, msg): # type: (mqtt.Client, tuple, mqtt.client
|
||||
|
||||
payload = msg.payload.decode()
|
||||
if not event_client_received_correct.is_set() and payload == "data":
|
||||
client.subscribe("/topic/binary")
|
||||
client.publish("/topic/qos0", "send binary please")
|
||||
if msg.topic == "/topic/qos0" and payload == "data":
|
||||
client.subscribe("topic/binary")
|
||||
client.publish("topic/qos0", "send binary please")
|
||||
if msg.topic == "topic/qos0" and payload == "data":
|
||||
event_client_received_correct.set()
|
||||
message_log += "Received data:" + msg.topic + " " + payload + "\n"
|
||||
|
||||
|
||||
@@ -104,10 +104,10 @@ I (4684) MQTTS_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTTS_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
@@ -61,11 +61,11 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -75,7 +75,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -72,11 +72,10 @@ I (4684) MQTTS_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTTS_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTTS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -84,7 +84,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -68,11 +68,10 @@ D (4750) MQTT_CLIENT: Connected
|
||||
I (4760) MQTTS_EXAMPLE: MQTT_EVENT_CONNECTED
|
||||
D (4760) MQTT_CLIENT: mqtt_enqueue id: 4837, type=8 successful
|
||||
D (4770) OUTBOX: ENQUEUE msgid=4837, msg_type=8, len=18, size=18
|
||||
D (4770) MQTT_CLIENT: Sent subscribe topic=/topic/qos0, id: 4837, type=8 successful
|
||||
D (4770) MQTT_CLIENT: Sent subscribe topic=topic/qos0, id: 4837, type=8 successful
|
||||
I (4780) MQTTS_EXAMPLE: sent subscribe successful, msg_id=4837
|
||||
D (4790) MQTT_CLIENT: mqtt_enqueue id: 58982, type=8 successful
|
||||
D (4790) OUTBOX: ENQUEUE msgid=58982, msg_type=8, len=18, size=36
|
||||
D (4800) MQTT_CLIENT: Sent subscribe topic=/topic/qos1, id: 58982, type=8 successful
|
||||
D (4800) MQTT_CLIENT: Sent subscribe topic=topic/qos1, id: 58982, type=8 successful
|
||||
I (4810) MQTTS_EXAMPLE: sent subscribe successful, msg_id=58982
|
||||
```
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -91,7 +91,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ I (4684) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTT_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTT_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTT_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
@@ -200,10 +200,10 @@ I (10603) mqtt_example: MQTT_EVENT_SUBSCRIBED, msg_id=2358
|
||||
I (10613) mqtt_example: sent publish successful, msg_id=0
|
||||
I (10613) mqtt_example: MQTT_EVENT_UNSUBSCRIBED, msg_id=57769
|
||||
I (10713) mqtt_example: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (10863) mqtt_example: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
@@ -364,12 +364,12 @@ I (13415) mqtt_example: sent publish successful, msg_id=0
|
||||
I (13415) mqtt_example: MQTT_EVENT_SUBSCRIBED, msg_id=36633
|
||||
I (13415) mqtt_example: sent publish successful, msg_id=0
|
||||
I (13425) mqtt_example: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos1
|
||||
TOPIC=topic/qos1
|
||||
DATA=data_3
|
||||
I (13435) mqtt_example: MQTT_EVENT_UNSUBSCRIBED, msg_id=15480
|
||||
I (13615) mqtt_example: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (13925) mqtt_example: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
```
|
||||
|
||||
@@ -55,13 +55,13 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos1", "data_3", 0, 1, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -71,7 +71,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -51,11 +51,10 @@ I (4684) MQTTWS_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTTWS_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTTWS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTTWS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos1", "data_3", 0, 1, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -79,7 +79,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def on_connect(client, userdata, flags, rc): # type: (mqtt.Client, tuple, bool,
|
||||
_ = (userdata, flags)
|
||||
print("Connected with result code " + str(rc))
|
||||
event_client_connected.set()
|
||||
client.subscribe("/topic/qos0")
|
||||
client.subscribe("topic/qos0")
|
||||
|
||||
|
||||
def mqtt_client_task(client): # type: (mqtt.Client) -> None
|
||||
@@ -39,8 +39,8 @@ def on_message(client, userdata, msg): # type: (mqtt.Client, tuple, mqtt.client
|
||||
global message_log
|
||||
payload = msg.payload.decode()
|
||||
if not event_client_received_correct.is_set() and payload == "data":
|
||||
client.publish("/topic/qos0", "data_to_esp32")
|
||||
if msg.topic == "/topic/qos0" and payload == "data":
|
||||
client.publish("topic/qos0", "data_to_esp32")
|
||||
if msg.topic == "topic/qos0" and payload == "data":
|
||||
event_client_received_correct.set()
|
||||
message_log += "Received data:" + msg.topic + " " + payload + "\n"
|
||||
|
||||
|
||||
@@ -61,13 +61,12 @@ I (4684) MQTTWSS_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=42970
|
||||
I (4684) MQTTWSS_EXAMPLE: sent publish successful, msg_id=0
|
||||
I (4884) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (4884) MQTTWSS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
I (5194) MQTT_CLIENT: deliver_publish, message_length_read=19, message_length=19
|
||||
I (5194) MQTTWSS_EXAMPLE: MQTT_EVENT_DATA
|
||||
TOPIC=/topic/qos0
|
||||
TOPIC=topic/qos0
|
||||
DATA=data
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
|
||||
switch (event->event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
@@ -67,7 +67,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d, return code=0x%02x ", event->msg_id, (uint8_t)*event->data);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
msg_id = esp_mqtt_client_publish(client, "topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def on_connect(client, userdata, flags, rc): # type: (mqtt.Client, tuple, bool,
|
||||
_ = (userdata, flags)
|
||||
print("Connected with result code " + str(rc))
|
||||
event_client_connected.set()
|
||||
client.subscribe("/topic/qos0")
|
||||
client.subscribe("topic/qos0")
|
||||
|
||||
|
||||
def mqtt_client_task(client): # type: (mqtt.Client) -> None
|
||||
@@ -41,8 +41,8 @@ def on_message(client, userdata, msg): # type: (mqtt.Client, tuple, mqtt.client
|
||||
global message_log
|
||||
payload = msg.payload.decode()
|
||||
if not event_client_received_correct.is_set() and payload == "data":
|
||||
client.publish("/topic/qos0", "data_to_esp32")
|
||||
if msg.topic == "/topic/qos0" and payload == "data":
|
||||
client.publish("topic/qos0", "data_to_esp32")
|
||||
if msg.topic == "topic/qos0" and payload == "data":
|
||||
event_client_received_correct.set()
|
||||
message_log += "Received data:" + msg.topic + " " + payload + "\n"
|
||||
|
||||
|
||||
@@ -68,13 +68,13 @@ static void mqtt_app_start(void)
|
||||
esp_mqtt_client_register_event(client, MQTT_EVENT_ANY, mqtt_event_handler, client);
|
||||
esp_mqtt_client_start(client);
|
||||
esp_mqtt_set_config(client, &mqtt_cfg);
|
||||
int msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data", 0, 0, 0);
|
||||
int msg_id = esp_mqtt_client_publish(client, "topic/qos1", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "mqtt api returned %d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "mqtt api returned %d", msg_id);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
msg_id = esp_mqtt_client_subscribe(client, "topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "mqtt api returned %d", msg_id);
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "topic/qos1");
|
||||
ESP_LOGI(TAG, "mqtt api returned %d", msg_id);
|
||||
esp_err_t err = esp_mqtt_client_set_uri(client, "mqtt://localhost:1883");
|
||||
ESP_LOGI(TAG, "mqtt api returned %d", err);
|
||||
|
||||
@@ -53,7 +53,7 @@ TEST(mqtt5, init_and_deinit)
|
||||
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
||||
.credentials.username = "123",
|
||||
.credentials.authentication.password = "456",
|
||||
.session.last_will.topic = "/topic/will",
|
||||
.session.last_will.topic = "topic/will",
|
||||
.session.last_will.msg = "i will leave",
|
||||
.session.last_will.msg_len = 12,
|
||||
.session.last_will.qos = 1,
|
||||
@@ -70,7 +70,7 @@ TEST(mqtt5, init_and_deinit)
|
||||
.payload_format_indicator = true,
|
||||
.message_expiry_interval = 10,
|
||||
.content_type = "json",
|
||||
.response_topic = "/test/response",
|
||||
.response_topic = "test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
};
|
||||
@@ -110,7 +110,7 @@ TEST(mqtt5, enqueue_and_destroy_outbox)
|
||||
.payload_format_indicator = 1,
|
||||
.message_expiry_interval = 1000,
|
||||
.topic_alias = 0,
|
||||
.response_topic = "/topic/test/response",
|
||||
.response_topic = "topic/test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
.content_type = "json",
|
||||
|
||||
@@ -158,7 +158,7 @@ bool mqtt5_subscribe_publish(void)
|
||||
.payload_format_indicator = 1,
|
||||
.message_expiry_interval = 1000,
|
||||
.topic_alias = 1,
|
||||
.response_topic = "/topic/test/response",
|
||||
.response_topic = "topic/test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
.content_type = "json",
|
||||
@@ -217,7 +217,7 @@ bool mqtt5_lwt_clean_disconnect(void)
|
||||
.payload_format_indicator = true,
|
||||
.message_expiry_interval = 10,
|
||||
.content_type = "json",
|
||||
.response_topic = "/test/response",
|
||||
.response_topic = "test/response",
|
||||
.correlation_data = "123456",
|
||||
.correlation_data_len = 6,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user