add resubscribe (in progress)
fix crash when no bus found in map
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user