OpenWB native: release GPIOs when closing (#28532)

This commit is contained in:
andig 2026-03-24 18:42:04 +01:00 • committed by GitHub
parent 5822750fe8
commit 3059749ece
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,7 +79,6 @@ func NewOpenWbNativeFromConfig(ctx context.Context, other map[string]any) (api.C
// NewOpenWbNative creates OpenWbNative charger
func NewOpenWbNative(ctx context.Context, uri, device, comset string, baudrate int, proto modbus.Protocol, slaveID uint8, hasPhases1p3p bool, rfIdVidPid string, cpWait time.Duration, connector int, chip string) (api.Charger, error) {
log := util.NewLogger("openwb-native")
log.DEBUG.Printf("Creating OpenWB native with 3 phases %t, rfid %s, cpwait %s, connector %d", hasPhases1p3p, rfIdVidPid, cpWait.String(), connector)
evse, err := NewEvseDIN(ctx, uri, device, comset, baudrate, proto, slaveID)
if err != nil {
@ -135,6 +134,13 @@ func NewOpenWbNative(ctx context.Context, uri, device, comset string, baudrate i
*gpioConfig.dst = line
}
go func() {
<-ctx.Done()
wb.gpio.cp.Close()
wb.gpio.ph1.Close()
wb.gpio.ph3.Close()
}()
return decorateOpenWbNative(wb, maxCurrentMillis, phases1p3p, identify), nil
}