UART & Sensors
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
def as_json(data):
|
||||
"""Convert a dictionary to a JSON string."""
|
||||
try:
|
||||
return json.dumps(data)
|
||||
except Exception as e:
|
||||
print("[Payloads] Error converting to JSON:", e)
|
||||
return "{}" # Return an empty JSON object on error
|
||||
|
||||
def mqtt_hello(id_microwave):
|
||||
return as_json({
|
||||
"id_microwave": id_microwave
|
||||
})
|
||||
|
||||
def mqtt_hello_ack(id_orchestrator, id_microwave):
|
||||
return as_json({
|
||||
"id_microwave": id_microwave,
|
||||
"id_orchestrator": id_orchestrator
|
||||
})
|
||||
Reference in New Issue
Block a user