From aa542bf1ab683c055fd200e41e7247a0c2347a25 Mon Sep 17 00:00:00 2001 From: Stedd Date: Wed, 18 Oct 2023 21:02:42 +0200 Subject: [PATCH] nope --- UdpMocker.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 UdpMocker.py diff --git a/UdpMocker.py b/UdpMocker.py new file mode 100644 index 0000000..5909312 --- /dev/null +++ b/UdpMocker.py @@ -0,0 +1,29 @@ +import socket +import time + +# UDP Configuration +ip = "localhost" # Change this to the IP address of your computer or the network address to multicast +port = 27019 # Ensure this matches the port number in your Unity script + +# Create the UDP socket +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +print("Starting UDP sending") +while True: + # Create some mock data + mock_data = { + "temperature": 72.4, + "humidity": 45.3, + "battery": 95.2, + } + + # Convert the mock data to a string and then to bytes + message = str(mock_data) + message_bytes = message.encode('utf-8') + + # Send the mock data + sock.sendto(message_bytes, (ip, port)) + print(message_bytes) + + # Wait for a bit before sending the next packet + time.sleep(1)