-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (19 loc) · 805 Bytes
/
main.py
File metadata and controls
25 lines (19 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import electroServer.electrolink as electrolink
import modules.electroFiles as electroFiles
from json import loads
import time
config = loads((open("config.json", "r").read()))
# Give board a server name
e = electrolink.Electrolink(config["device_id"], config["command_topic"], config["reply_topic"], config["error_topic"])
# extend Electrolink with additional fnctions
e.addCallbacks(electroFiles.callbacks)
# assuming that machine is already connected to Internet
# Broker MQTT server, mqtt protocol default port 1883
e.connectToServer(config["broker_server"])
while True:
# blocking function, waiting for new message
#e.waitForMessage()
time.sleep(0.5)
# or use non-blocking message to do something else in this file
# while checking for new messages
#e.checkForMessage()