1
0
mirror of https://github.com/daniviga/bite.git synced 2025-04-20 14:31:20 +02:00

Fix simulator.py

This commit is contained in:
Daniele Viganò 2020-06-21 11:52:15 +02:00
parent d57f6dc5c0
commit 3b4419e4e6
Signed by: dani
GPG Key ID: DB49AFC03C40EE02
2 changed files with 5 additions and 5 deletions

View File

@ -26,10 +26,10 @@ services:
environment:
IOT_HTTP: "http://ingress"
IOT_MQTT: "ingress:80"
# IOT_SERIAL: "websockets1234"
# IOT_SERIAL: "ws"
# IOT_DELAY: 10
IOT_DEBUG: 1
command: ["/opt/bite/device_simulator.py", "-t", "websockets"]
command: ["/opt/bite/device_simulator.py", "-t", "ws"]
network_mode: "host"
device-mqtt:

View File

@ -52,7 +52,7 @@ def publish_json(transport, endpoint, data):
hostname=endpoint.split(':')[0],
port=int(endpoint.split(':')[1]),
client_id=serial,
transport=transport,
transport=('websockets' if transport == 'ws' else 'tcp'),
# auth=auth FIXME
)
@ -70,7 +70,7 @@ def main():
'127.0.0.1:1883'),
help='IoT MQTT endpoint')
parser.add_argument('-t', '--transport',
choices=['mqtt', 'websockets', 'http'],
choices=['mqtt', 'ws', 'http'],
default=os.environ.get('IOT_TL', 'http'),
help='IoT transport layer')
parser.add_argument('-s', '--serial',
@ -104,7 +104,7 @@ def main():
}
if args.transport == 'http':
post_json(args.endpoint, telemetry, {**data, 'payload': payload})
elif args.transport in ('mqtt', 'websockets'):
elif args.transport in ('mqtt', 'ws'):
publish_json(
args.transport, args.mqtt, {**data, 'payload': payload})
else: