resolve peripheral status

This commit is contained in:
2025-11-10 15:55:32 +01:00
parent f8b39d90de
commit 621c1922ca
3 changed files with 12 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ func (p *FTDIPeripheral) Connect(ctx context.Context) error {
serialNumber := C.CString(p.info.SerialNumber)
defer C.free(unsafe.Pointer(serialNumber))
if C.dmx_connect(p.dmxSender, serialNumber) != C.DMX_OK {
runtime.EventsEmit(ctx, string(PeripheralStatus), p.info, "disconnected")
log.Error().Str("file", "FTDIPeripheral").Str("s/n", p.info.SerialNumber).Msg("unable to connect the DMX device")
return errors.Errorf("unable to connect '%s'")
}
@@ -92,9 +93,11 @@ func (p *FTDIPeripheral) Activate(ctx context.Context) error {
err := C.dmx_activate(p.dmxSender)
if err != C.DMX_OK {
runtime.EventsEmit(ctx, string(PeripheralStatus), p.info, "deactivated")
return errors.Errorf("unable to activate the DMX sender!")
}
// Test only
C.dmx_setValue(p.dmxSender, C.uint16_t(1), C.uint8_t(255))
C.dmx_setValue(p.dmxSender, C.uint16_t(5), C.uint8_t(255))