0
0
IOT Protocolsdevops~10 mins

Edge gateway architecture in IOT Protocols - Interactive Code Practice

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

Complete the code to define the main function of an edge gateway.

IOT Protocols
def [1]():
    print("Edge gateway started")
Drag options to blanks, or click blank then click option'
Amain
Brun
Cgateway_init
Dstart_gateway
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-standard function names like 'start_gateway' or 'gateway_init'.
2fill in blank
medium

Complete the code to import the MQTT client library used in edge gateways.

IOT Protocols
import [1]
Drag options to blanks, or click blank then click option'
Ahttp.client
Bpaho.mqtt.client
Csocket
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like 'http.client' or 'json'.
3fill in blank
hard

Fix the error in the code to connect the edge gateway to the MQTT broker.

IOT Protocols
client = mqtt.Client()
client.[1]("broker.hivemq.com", 1883, 60)
Drag options to blanks, or click blank then click option'
Ainit
Bstart
Copen
Dconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like 'start' or 'init' which do not exist for connection.
4fill in blank
hard

Fill both blanks to subscribe the edge gateway to a topic and start the network loop.

IOT Protocols
client.[1]("sensors/temperature")
client.[2]()
Drag options to blanks, or click blank then click option'
Asubscribe
Bpublish
Cloop_start
Dloop_forever
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'publish' instead of 'subscribe' or 'loop_forever' which blocks execution.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps sensor IDs to their latest readings if the reading is above threshold.

IOT Protocols
sensor_data = [1]: [2] for [3], [2] in readings.items() if [2] > 50}
Drag options to blanks, or click blank then click option'
Asensor_id
Bvalue
Creadings
Dsensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names or wrong loop variable names.