MQTT-SN v1.2是否支持MQTT v5的请求-响应模式?
Short answer: No, MQTT-SN v1.2 does not natively support the standardized request-response pattern with a dedicated Response Topic attribute like MQTT v5 does.
Unlike MQTT v5, which defines explicit Response Topic and Correlation Data attributes in its PUBLISH packet structure to formalize request-response workflows, MQTT-SN v1.2 was built for low-bandwidth, constrained networks (perfect for your BLE use case) and has a far more minimal set of packet attributes. The specification doesn't include any built-in fields or standardized mechanisms to carry response topic metadata directly in PUBLISH packets.
That said, you can absolutely implement a fully functional request-response flow using MQTT-SN v1.2 by adding a custom "response topic" field in your message payload. This is the de facto approach for this scenario:
- The requesting client includes a field (e.g.,
response_topic) in the payload of its request PUBLISH message, specifying the topic where it expects to receive the response. - The responding client parses this payload field, performs the requested action, then publishes the response to the specified topic.
- The requesting client should subscribe to this response topic beforehand to receive the reply (mirroring the MQTT v5 flow).
Since MQTT-SN doesn't restrict the structure of your payload, this method works seamlessly—you just need to agree on the payload format (e.g., JSON, a custom binary structure) with the responding client to ensure the response_topic field is correctly parsed.
内容的提问来源于stack exchange,提问作者bluesky

