mirror of
https://github.com/daniviga/bite.git
synced 2025-04-20 22:41:18 +02:00
Fix simulator.py
This commit is contained in:
parent
d57f6dc5c0
commit
3b4419e4e6
@ -26,10 +26,10 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
IOT_HTTP: "http://ingress"
|
IOT_HTTP: "http://ingress"
|
||||||
IOT_MQTT: "ingress:80"
|
IOT_MQTT: "ingress:80"
|
||||||
# IOT_SERIAL: "websockets1234"
|
# IOT_SERIAL: "ws"
|
||||||
# IOT_DELAY: 10
|
# IOT_DELAY: 10
|
||||||
IOT_DEBUG: 1
|
IOT_DEBUG: 1
|
||||||
command: ["/opt/bite/device_simulator.py", "-t", "websockets"]
|
command: ["/opt/bite/device_simulator.py", "-t", "ws"]
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
device-mqtt:
|
device-mqtt:
|
||||||
|
@ -52,7 +52,7 @@ def publish_json(transport, endpoint, data):
|
|||||||
hostname=endpoint.split(':')[0],
|
hostname=endpoint.split(':')[0],
|
||||||
port=int(endpoint.split(':')[1]),
|
port=int(endpoint.split(':')[1]),
|
||||||
client_id=serial,
|
client_id=serial,
|
||||||
transport=transport,
|
transport=('websockets' if transport == 'ws' else 'tcp'),
|
||||||
# auth=auth FIXME
|
# auth=auth FIXME
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ def main():
|
|||||||
'127.0.0.1:1883'),
|
'127.0.0.1:1883'),
|
||||||
help='IoT MQTT endpoint')
|
help='IoT MQTT endpoint')
|
||||||
parser.add_argument('-t', '--transport',
|
parser.add_argument('-t', '--transport',
|
||||||
choices=['mqtt', 'websockets', 'http'],
|
choices=['mqtt', 'ws', 'http'],
|
||||||
default=os.environ.get('IOT_TL', 'http'),
|
default=os.environ.get('IOT_TL', 'http'),
|
||||||
help='IoT transport layer')
|
help='IoT transport layer')
|
||||||
parser.add_argument('-s', '--serial',
|
parser.add_argument('-s', '--serial',
|
||||||
@ -104,7 +104,7 @@ def main():
|
|||||||
}
|
}
|
||||||
if args.transport == 'http':
|
if args.transport == 'http':
|
||||||
post_json(args.endpoint, telemetry, {**data, 'payload': payload})
|
post_json(args.endpoint, telemetry, {**data, 'payload': payload})
|
||||||
elif args.transport in ('mqtt', 'websockets'):
|
elif args.transport in ('mqtt', 'ws'):
|
||||||
publish_json(
|
publish_json(
|
||||||
args.transport, args.mqtt, {**data, 'payload': payload})
|
args.transport, args.mqtt, {**data, 'payload': payload})
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user