add resubscribe (in progress)

fix crash when no bus found in map
This commit is contained in:
Adrian Zürcher
2025-05-28 22:00:04 +02:00
parent dc64d08e9d
commit b5d9d96c52
8 changed files with 72 additions and 17 deletions

View File

@@ -60,8 +60,8 @@ func (d *ArtNetDriver) LoadCfg() error {
return err
}
for _, b := range d.Buses {
d.NewBus(b.Name, b.Ip, *b.Port)
for name, b := range d.Buses {
d.NewBus(name, b.Ip, *b.Port)
}
return nil
}
@@ -77,10 +77,17 @@ func (d *ArtNetDriver) SetValue(bus string, address uint, value uint8) error {
if _, ok := d.Buses[bus]; !ok {
return fmt.Errorf("no bus '%s' found", bus)
}
if d.Buses[bus].Data == nil {
return fmt.Errorf("no dmx data on bus '%s' found", bus)
}
d.Buses[bus].Data.SetValue(address, value)
return d.Buses[bus].SendData()
}
// connect to websocket server and listen to subscriptions
// ip: ip address of server
// id: id of driver
// port: port of server
func (d *ArtNetDriver) Connect(ip, id string, port uint) error {
d.Conn = client.NewClient(d.Log)
if err := d.Conn.Connect(ip, id, port); err != nil {