def async_mqtt_gateway(broker, port, **kwargs): """Start an async mqtt gateway.""" loop = asyncio.get_event_loop() mqttc = loop.run_until_complete(async_start_mqtt_client( loop, broker, port)) gateway = AsyncMQTTGateway(mqttc.publish, mqttc.subscribe, event_callback=handle_msg, loop=loop, **kwargs) run_async_gateway(gateway, mqttc.stop())
def async_serial_gateway(**kwargs): """Start an async serial gateway.""" gateway = AsyncSerialGateway(event_callback=handle_msg, **kwargs) run_async_gateway(gateway)
def async_tcp_gateway(**kwargs): """Start an async tcp gateway.""" gateway = AsyncTCPGateway(event_callback=handle_msg, **kwargs) run_async_gateway(gateway)