Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start the edge translator service.
IOT Protocols
edge_translator.start([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using method calls instead of file names
Using incorrect file names
✗ Incorrect
The service requires the configuration file config.yaml to start properly.
2fill in blank
mediumComplete the code to translate MQTT messages to CoAP format.
IOT Protocols
translator.convert('mqtt', 'coap', message[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using method calls instead of properties
Using incorrect property names
✗ Incorrect
The payload property contains the actual message data to translate.
3fill in blank
hardFix the error in the code to correctly map CoAP requests to MQTT topics.
IOT Protocols
mapping = {req.topic: req[1] for req in coap_requests} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using topic as value instead of payload
Using incorrect property names
✗ Incorrect
The payload contains the data to be sent to the MQTT topic.
4fill in blank
hardFill both blanks to filter and translate only temperature sensor data.
IOT Protocols
filtered = {msg[1]: translator.convert('mqtt', 'coap', msg[2]) for msg in messages if 'temperature' in msg.topic} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using data or content instead of payload
Using payload as key instead of topic
✗ Incorrect
The dictionary keys are message topics, and the values are the converted payloads.
5fill in blank
hardFill all three blanks to create a mapping of device IDs to their latest translated messages.
IOT Protocols
latest_messages = [1]{msg.device_id: translator.convert([2], [3], msg.payload) for msg in device_msgs if msg.status == 'active'}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict
Swapping protocol names
Missing parentheses
✗ Incorrect
We use dict( to create a dictionary, translating from MQTT to CoAP for active devices.