Beispiel #1
0
 def setUp(self):
     self.messages = []
     self.serial = Serial(None, None)
     self.xbee = XBeeWrapper()
     self.xbee.default_port_name = 'serial'
     self.xbee.serial = self.serial
     self.xbee.on_message = self.on_message
     self.xbee.connect()
Beispiel #2
0
    mqtt.password = config.get('mqtt', 'password', None)
    mqtt.keepalive = config.get('mqtt', 'keepalive', 60)
    mqtt.clean_session = config.get('mqtt', 'clean_session', False)
    mqtt.qos = config.get('mqtt', 'qos', 0)
    mqtt.retain = config.get('mqtt', 'retain', True)
    mqtt.set_will = config.get('mqtt', 'set_will', True)

    try:
        serial = Serial(
            config.get('radio', 'port', '/dev/ttyUSB0'),
            config.get('radio', 'baudrate', 9600)
        )
    except SerialException as e:
        sys.exit(e)

    xbee = XBeeWrapper()
    xbee.serial = serial
    xbee.default_port_name = config.get('radio', 'default_port_name', 'serial')
    xbee.sample_rate = config.get('general', 'sample_rate', 0)
    xbee.change_detection = config.get('general', 'change_detection', False)

    processor = Processor(config.get('processor', 'filters', []))

    xbee2mqtt = Xbee2MQTT(resolve_path(config.get('daemon', 'pidfile', '/tmp/xbee2mqtt.pid')))
    xbee2mqtt.stdout = resolve_path(config.get('daemon', 'stdout', '/dev/null'))
    xbee2mqtt.stderr = resolve_path(config.get('daemon', 'stderr', xbee2mqtt.stdout))
    xbee2mqtt.discovery_on_connect = config.get('general', 'discovery_on_connect', True)
    xbee2mqtt.duplicate_check_window = config.get('general', 'duplicate_check_window', 5)
    xbee2mqtt.default_output_topic_pattern = config.get(
        'general', 'default_output_topic_pattern', '/raw/xbee/{address}/{port}'
    )