|
|
|
|
|
|
|
|
my_database.create_tables() |
|
|
my_database.create_tables() |
|
|
|
|
|
|
|
|
# Create MQTT Client and connect to local broker |
|
|
# Create MQTT Client and connect to local broker |
|
|
mqttclient = mqtt.Client(BACKEND_CLIENT_ID, transport="websockets") # transport websockets required for local broker |
|
|
|
|
|
|
|
|
mqttclient = mqtt.Client(BACKEND_CLIENT_ID, """transport="websockets""""") # transport websockets required for local broker |
|
|
mqttclient.on_connect = lambda client, userdata, flags, rc: on_connect(_client=client, |
|
|
mqttclient.on_connect = lambda client, userdata, flags, rc: on_connect(_client=client, |
|
|
_userdata=userdata, |
|
|
_userdata=userdata, |
|
|
_flags=flags, |
|
|
_flags=flags, |
|
|
_rc=rc, |
|
|
_rc=rc, |
|
|
_mydatabase=my_database, |
|
|
_mydatabase=my_database, |
|
|
_robot=robot) |
|
|
_robot=robot) |
|
|
mqttclient.connect(MQTT_BROKER_LOCAL) |
|
|
|
|
|
|
|
|
mqttclient.connect(MQTT_BROKER_GLOBAL) |
|
|
|
|
|
|
|
|
# Initialize logger and save in server.log file |
|
|
# Initialize logger and save in server.log file |
|
|
logging.basicConfig(filename="server.log", filemode="a", encoding="utf-8", level=logging.DEBUG, |
|
|
logging.basicConfig(filename="server.log", filemode="a", encoding="utf-8", level=logging.DEBUG, |