# UDP server zur annahme der sensordten und weitergabe an MQTT Brocker in Form eines JSON Paketes import socket from datetime import datetime import numpy import paho.mqtt.client as mqtt import json import ipadress #UDP Socket Setup UDP_IP_ADDRESS = "192.168.178.45" # IP vom Server (Empfanger-Standpunkt) UDP_PORT_NO = 8888 service_ip = ipadress.get_ip() service_name = 'UDPtoMQTT Service' service_status = True serverSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) serverSock.bind((UDP_IP_ADDRESS, UDP_PORT_NO)) print ('UDP Server up: ' + str(UDP_PORT_NO)) #MQTT Publisher Setup broker_adress = "192.168.178.45" serviceClient = mqtt.Client() serviceClient.connect(broker_adress) serviceClient.loop_start() print('MQTT Client up')
# UDP server zur annahme der sensordten und weitergabe an MQTT Brocker in Form eines JSON Paketes import socket from datetime import datetime import paho.mqtt.client as mqtt import json import ipadress import os #UDP Socket Setup ip = ipadress.get_ip() #ermittelt die IP Adresse des Containers UDP_IP_ADDRESS = str(ip) # IP vom Server (Empfanger-Standpunkt) UDP_PORT_NO = int(os.environ['UDPPORT']) serverSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #UDP Socket erstellen serverSock.bind((UDP_IP_ADDRESS, UDP_PORT_NO)) print('UDP Server up: ' + str(UDP_PORT_NO)) #MQTT Publisher Setup broker_adress = "192.168.178.45" serviceClient = mqtt.Client() serviceClient.connect(broker_adress) serviceClient.loop_start() print('MQTT Client up') print('UDPtoMQTT_Service IP: ', str(ip)) def zeitformat(zeit):