12345678910111213141516171819202122232425262728293031323334353637383940 |
- import config
- import devdi.devices as devices
- import logging
- import mqtt
- import report
- import z_protocol
- import socket_protocol
- import tcp_socket
- import time
-
- logger = logging.getLogger(config.APP_NAME)
-
-
- if __name__ == "__main__":
- #
- # Logging
- #
- if config.DEBUG:
- report.appLoggingConfigure(None, 'stdout', ((config.APP_NAME, logging.DEBUG), ),
- target_level=logging.WARNING, fmt=report.SHORT_FMT, host='localhost', port=19996)
- else:
- report.stdoutLoggingConfigure(((config.APP_NAME, config.LOGLEVEL), ), report.SHORT_FMT)
-
- #
- # MQTT Client
- #
- mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
- password=config.MQTT_PASSWORD, name=config.APP_NAME)
- #
- # Smarthome physical Devices
- #
- pd = devices.physical_devices(mc)
-
- #
- # Socket Protocol
- #
- s = tcp_socket.tcp_server_stp('127.0.0.1', config.SOCK_PROT_PORT)
- sp = z_protocol.server(s, channel_name='example_server', devices=pd)
- while (True):
- time.sleep(5)
|