Ocpp: fix empty chargepoint id when auto-discovered (#4512)

This commit is contained in:
andig 2022-09-18 18:11:33 +02:00 • committed by GitHub
parent 8b88693d40
commit 831f27b598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,7 +24,6 @@ const statusTimeout = 30 * time.Second
type OCPP struct {
log *util.Logger
cp *ocpp.CP
id string
connector int
idtag string
phases int
@ -104,7 +103,6 @@ func NewOCPP(id string, connector int, idtag string, meterValues string, meterIn
c := &OCPP{
log: util.NewLogger(unit),
cp: cp,
id: id,
connector: connector,
idtag: idtag,
}
@ -228,7 +226,7 @@ func (c *OCPP) hasMeasurement(val types.Measurand) bool {
func (c *OCPP) configure(key, val string) error {
rc := make(chan error, 1)
err := ocpp.Instance().ChangeConfiguration(c.id, func(resp *core.ChangeConfigurationConfirmation, err error) {
err := ocpp.Instance().ChangeConfiguration(c.cp.ID(), func(resp *core.ChangeConfigurationConfirmation, err error) {
c.log.TRACE.Printf("ChangeConfiguration: %v", resp)
if err == nil && resp != nil && resp.Status != core.ConfigurationStatusAccepted {
@ -270,7 +268,7 @@ func (c *OCPP) Enable(enable bool) error {
rc := make(chan error, 1)
if enable {
err = ocpp.Instance().RemoteStartTransaction(c.id, func(resp *core.RemoteStartTransactionConfirmation, err error) {
err = ocpp.Instance().RemoteStartTransaction(c.cp.ID(), func(resp *core.RemoteStartTransactionConfirmation, err error) {
c.log.TRACE.Printf("RemoteStartTransaction: %+v", resp)
if err == nil && resp != nil && resp.Status != types.RemoteStartStopStatusAccepted {
@ -282,7 +280,7 @@ func (c *OCPP) Enable(enable bool) error {
request.ConnectorId = &c.connector
})
} else {
err = ocpp.Instance().RemoteStopTransaction(c.id, func(resp *core.RemoteStopTransactionConfirmation, err error) {
err = ocpp.Instance().RemoteStopTransaction(c.cp.ID(), func(resp *core.RemoteStopTransactionConfirmation, err error) {
c.log.TRACE.Printf("RemoteStopTransaction: %+v", resp)
if err == nil && resp != nil && resp.Status != types.RemoteStartStopStatusAccepted {
@ -300,7 +298,7 @@ func (c *OCPP) setChargingProfile(connectorid int, profile *types.ChargingProfil
c.log.TRACE.Printf("SetChargingProfileRequest: %+v (%+v)", profile, *profile.ChargingSchedule)
rc := make(chan error, 1)
err := ocpp.Instance().SetChargingProfile(c.id, func(resp *smartcharging.SetChargingProfileConfirmation, err error) {
err := ocpp.Instance().SetChargingProfile(c.cp.ID(), func(resp *smartcharging.SetChargingProfileConfirmation, err error) {
c.log.TRACE.Printf("SetChargingProfile: %+v", resp)
if err == nil && resp != nil && resp.Status != smartcharging.ChargingProfileStatusAccepted {
err = errors.New(string(resp.Status))