parent
59ed57c1c5
commit
acf8f01204
|
@ -3,7 +3,7 @@ import json
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import threading
|
import threading
|
||||||
from stupidArtnet import StupidArtnet
|
import sacn
|
||||||
import os
|
import os
|
||||||
from getmac import get_mac_address
|
from getmac import get_mac_address
|
||||||
import netifaces
|
import netifaces
|
||||||
|
@ -114,15 +114,19 @@ def connect_mqtt():
|
||||||
|
|
||||||
|
|
||||||
def mqtt_publisher(universe):
|
def mqtt_publisher(universe):
|
||||||
|
universe = universe-1
|
||||||
mqtt_client = connect_mqtt()
|
mqtt_client = connect_mqtt()
|
||||||
try:
|
try:
|
||||||
# Create a new Art-Net listener
|
receiver = sacn.sACNreceiver(bind_address=get_eth0_ip())
|
||||||
artnet = StupidArtnet(target_ip=get_eth0_ip(), universe=universe)
|
receiver.start()
|
||||||
artnet.start()
|
|
||||||
|
|
||||||
|
@receiver.listen_on('universe', universe=universe) # listens on universe 1
|
||||||
|
def sacn_callback(packet): # packet type: sacn.DataPacket
|
||||||
|
print(packet.dmxData)
|
||||||
|
global dmx_values
|
||||||
|
dmx_values = packet.dmxData
|
||||||
|
receiver.join_multicast()
|
||||||
while True:
|
while True:
|
||||||
dmx_values = artnet.listen()
|
|
||||||
print(str(dmx_values))
|
|
||||||
if dmx_values is not None:
|
if dmx_values is not None:
|
||||||
for channel, value in enumerate(dmx_values):
|
for channel, value in enumerate(dmx_values):
|
||||||
# Create MQTT topic based on the universe and channel
|
# Create MQTT topic based on the universe and channel
|
||||||
|
@ -136,7 +140,7 @@ def mqtt_publisher(universe):
|
||||||
print(f"Error in universe {universe}: {e}")
|
print(f"Error in universe {universe}: {e}")
|
||||||
|
|
||||||
def start_mqtt_publishers(universe_count):
|
def start_mqtt_publishers(universe_count):
|
||||||
used_universes = universe_count - 1
|
used_universes = universe_count
|
||||||
print("universe count: "+str(used_universes))
|
print("universe count: "+str(used_universes))
|
||||||
universes_to_publish = list(range(1, used_universes + 1))
|
universes_to_publish = list(range(1, used_universes + 1))
|
||||||
# Create and start a thread for each universe
|
# Create and start a thread for each universe
|
||||||
|
|
Loading…
Reference in New Issue