0
0
IOT Protocolsdevops~10 mins

Why hands-on MQTT implementation matters in IOT Protocols - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to connect an MQTT client to a broker.

IOT Protocols
client.connect('[1]')
Drag options to blanks, or click blank then click option'
Amqtt.example.com
Blocalhost
C192.168.1.1
Dbroker.hivemq.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using an IP address that is not reachable
Leaving the broker address empty
Using localhost when the broker is remote
2fill in blank
medium

Complete the code to subscribe to the topic 'home/temperature'.

IOT Protocols
client.subscribe('[1]')
Drag options to blanks, or click blank then click option'
Ahome/temperature
Bhome/pressure
Coffice/temperature
Dhome/humidity
Attempts:
3 left
💡 Hint
Common Mistakes
Subscribing to the wrong topic
Using a topic with a typo
Using a topic from a different location
3fill in blank
hard

Fix the error in publishing a message to 'home/light'.

IOT Protocols
client.publish('[1]', 'ON')
Drag options to blanks, or click blank then click option'
Ahome_light
Bhome/light
Chome/light/status
Dhome.light
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores instead of slashes
Using dots instead of slashes
Adding extra topic levels unintentionally
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps topics to their message lengths.

IOT Protocols
{topic: len([1]) for topic, [2] in messages.items()}
Drag options to blanks, or click blank then click option'
Amessage
Bmsg
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for both blanks
Using a variable not defined in the loop
Confusing topic and message variables
5fill in blank
hard

Fill all three blanks to filter messages with payload length greater than 5 and create a new dictionary with uppercase topics.

IOT Protocols
{topic.upper(): [1] for topic, [2] in messages.items() if len([3]) > 5}
Drag options to blanks, or click blank then click option'
Apayload
Bmsg
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names between blanks
Using topic instead of message for length check
Not converting topic to uppercase