Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Alfen OCPP Authorization Flow #16088

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charger/ocpp/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
KeyMaxChargingProfilesInstalled = "MaxChargingProfilesInstalled"

// Vendor specific keys
KeyAlfenAuthorizationMethod = "AuthorizationMethod"
KeyAlfenPlugAndChargeIdentifier = "PlugAndChargeIdentifier"
KeyEvBoxSupportedMeasurands = "evb_SupportedMeasurands"
)
8 changes: 8 additions & 0 deletions charger/ocpp/cp_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (cp *CP) Authorize(request *core.AuthorizeRequest) (*core.AuthorizeConfirma
},
}

// Set idTag for all connectors in available state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das fühlt sich komisch an. Wenn die WB das Tag bei der Initialisierung mit gibt- warum ist das hier notwendig?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Korrigier mich wenn ich falsch liege aber die Logik aus dem init / cp_setup läuft beim Start wenn der erste Kontakt mit der Wallbox aufgenommen wird. Hier werden die Einstellungen abgeglichen und z.B. die Plug and Charge ID übernommen (falls konfiguriert).

Der Auth / cp_core wird ausgeführt wenn eine RFID Karte an die Wallbox gehalten wird um eine neue Transaktion zu autorisieren. Hier können wir also den idTag für den bevorstehenden Ladevorgang abgreifen.

Die Art und Weisse wie man das am besten machen kann ohne den konkreten Connector zu kennen ist wohl die große Frage.

for _, conn := range cp.connectors {
if conn.status.Status == core.ChargePointStatusAvailable {
conn.log.INFO.Printf("Set idTag %v from Authorization request", request.IdTag)
conn.idTag = request.IdTag
}
}

return res, nil
}

Expand Down
19 changes: 17 additions & 2 deletions charger/ocpp/cp_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error {

// vendor-specific keys
case KeyAlfenPlugAndChargeIdentifier:
cp.IdTag = *opt.Value
cp.log.DEBUG.Printf("overriding default `idTag` with Alfen-specific value: %s", cp.IdTag)
authMethod, ok := getConfigurationValue(resp, KeyAlfenAuthorizationMethod)

// Override `idTag` with plug-and-charge id if PLUG_AND_CHARGE is configured
if ok && authMethod != "RFID" {
cp.IdTag = *opt.Value
cp.log.DEBUG.Printf("Alfen-specific: overriding `idTag` with PLUG_AND_CHARGE value: %s", cp.IdTag)
}

case KeyEvBoxSupportedMeasurands:
if meterValues == "" {
Expand Down Expand Up @@ -146,6 +151,16 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error {
return nil
}

// getConfigurationValue returns the value of a configuration key
func getConfigurationValue(resp *core.GetConfigurationConfirmation, key string) (string, bool) {
for _, opt := range resp.ConfigurationKey {
if opt.Key == key && opt.Value != nil {
return *opt.Value, true
}
}
return "", false
}

// GetConfiguration
func (cp *CP) GetConfiguration() (*core.GetConfigurationConfirmation, error) {
rc := make(chan error, 1)
Expand Down