Skip to content
Snippets Groups Projects
Select Git revision
  • 2a625d4e6d06fb32fbf48834fdfff4a81be454f7
  • main default protected
  • nour2
  • aleks4
  • geno2
  • petri-net-output
  • nour
  • deep-rl-1
  • geno3
  • paula
  • aleks2
  • aleks3
  • Nour
  • geno
  • aleks
15 results

businessprocess.py

Blame
  • receive.py 1.10 KiB
    import time
    
    from src import mqtt
    
    logger = mqtt.root_logger.get('Receiver')
    
    ### Ask for settings and individual credentials ###
    
    MQTT_USER = ""
    MQTT_PASSWORD = ""
    
    MQTT_BROKER = "mqtt.wzl-mq.rwth-aachen.de"
    MQTT_PORT = 8883
    MQTT_VHOST = "metrology"
    
    ## to connect to the central MQTT-Broker of MQ-MS use the following settings:
    # MQTT_BROKER = "wzl-mbroker01.wzl.rwth-aachen.de"
    # MQTT_PORT = 1883
    # MQTT_VHOST = "metrology"
    
    ### Ask for settings and individual credentials ###
    
    topic = "#" # set topic to subscribe according to MQTT syntax!
    qos = 0 # set QoS according to MQTT specifications!
    
    def print_mqtt_message(topic, message):
        logger.info("### {} ###\r\n{}\r\n".format(topic, message.decode("utf-8")))
    
    if __name__=="__main__":
        client = mqtt.MQTTSubscriber(prefix="bdn-212d8419-c75c-471f-8ea5-f3a5c19ac42e")
        client.connect(MQTT_BROKER, MQTT_PORT, MQTT_VHOST + ":" + MQTT_USER, vhost=MQTT_VHOST, MQTT_PASSWORD)
    
        client.set_callback("PRINT", print_mqtt_message)
        # client.subscribe(topic, qos)
    
        while True:
            try:
                time.sleep(1)
            except KeyboardInterrupt:
                break