From 7c45557541d34ca8eeaf277e2901b590f06947b2 Mon Sep 17 00:00:00 2001 From: will Date: Mon, 19 Aug 2024 23:11:12 +0100 Subject: [PATCH] Added binding to specific interface automatically interface name is currently hard-coded as "wlo1" for testing reasons --- clock.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clock.py b/clock.py index 759fbe8..44cf4f4 100755 --- a/clock.py +++ b/clock.py @@ -8,6 +8,9 @@ import time import sacn import sys import os +import socket +import struct +import fcntl # fake GPIO dummy class for debuging class dummy(): @@ -123,7 +126,13 @@ class clock(): def light(self): print("starting lighting service...") - sender = sacn.sACNsender() + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + packed_interface = struct.pack('256s', "wlo1".encode('utf_8')) + packed_address = fcntl.ioctl(sock.fileno(), 0x8915, packed_interface)[20:24] + ip = socket.inet_ntoa(packed_address) + print(f"bound to {ip}...") + + sender = sacn.sACNsender(bind_address=ip, source_name="doomsday") sender.start() sender.activate_output(2) sender[2].multicast = True -- 2.39.2