summaryrefslogtreecommitdiff
path: root/main.py
blob: b50962a0c0e7d6634555f933ed74c7d8785119c9 (plain)
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
26
27
28
29
#!/usr/bin/python3


"""Main executable for the Package / Service"""


import iot_barcode_scanner as ibs


def main():
    try:
        config = ibs.get_config()
        mqtt_service = ibs.MqttService(config)
        mqtt_service.run()
        print("Starting Service")
        while True:
            text = input()
            mqtt_service.client.publish(
                config["mqtt"]["topic"],
                payload=text,
                qos=0,
                retain=False
            )
    except KeyboardInterrupt:
        print("Service stopped")


if __name__ == "__main__":
    main()