Bird
0
0

How can you modify the subscription to only receive control messages with payload 'START' and ignore others?

hard🚀 Application Q9 of 15
Raspberry Pi - MQTT for IoT
How can you modify the subscription to only receive control messages with payload 'START' and ignore others?
ASubscribe normally and filter messages in on_message callback by checking payload
BUse MQTT topic filter 'control/START' to receive only those messages
CSet broker to only forward 'START' messages to your client
DSubscribe to 'control/#' and use QoS 2 to filter payloads
Step-by-Step Solution
Solution:
  1. Step 1: Understand MQTT topic filtering limits

    MQTT topics filter by topic name, not payload content.
  2. Step 2: Filter payload in client code

    Subscribe to relevant topics and check payload in on_message callback.
  3. Final Answer:

    Subscribe normally and filter messages in on_message callback by checking payload -> Option A
  4. Quick Check:

    Filter payload in callback, not via topic [OK]
Quick Trick: Filter payload inside on_message callback [OK]
Common Mistakes:
MISTAKES
  • Expecting topic filter to filter payload
  • Relying on broker to filter payload
  • Misusing QoS for filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes