Commit 252a4db9 authored by Daniel Kolibár's avatar Daniel Kolibár
Browse files

updated code

parent 6faeba73
......@@ -7,7 +7,7 @@ import base64
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected successfully to MQTT broker")
print(f"Connecting to MQTT broker failed with code {rc}")
......@@ -21,13 +21,17 @@ def on_message(client, userdata, msg):
camera.capture(photo, 'jpeg')
print('took photo!')
base64_bytes = base64.b64encode(my_stream.getvalue())
base64_bytes = base64.b64encode(photo.getvalue())
base64_message = base64_bytes.decode('ascii')
client.publish('birdie/rxtxfile', payload=base64_message, qos=0, retain=False)
client.publish('birdie/tx', payload=base64_message, qos=0, retain=False)
def on_publish(client,userdata,result):
print("published", result)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.on_publish = on_publish
client.connect("", 1883, 60)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment