Skip to content

Commit

Permalink
Ocpp: always send confirmation (#15950)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Sep 15, 2024
1 parent 229b2cf commit 009a9c2
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions charger/ocpp/cp_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,39 @@ func (cp *CP) MeterValues(request *core.MeterValuesRequest) (*core.MeterValuesCo
default:
}

conn := cp.connectorByID(request.ConnectorId)
if conn == nil {
return nil, ErrInvalidConnector
if conn := cp.connectorByID(request.ConnectorId); conn != nil {
conn.MeterValues(request)
}

return conn.MeterValues(request)
return new(core.MeterValuesConfirmation), nil
}

func (cp *CP) StartTransaction(request *core.StartTransactionRequest) (*core.StartTransactionConfirmation, error) {
if request == nil {
return nil, ErrInvalidRequest
}

conn := cp.connectorByID(request.ConnectorId)
if conn == nil {
return nil, ErrInvalidConnector
if conn := cp.connectorByID(request.ConnectorId); conn != nil {
return conn.StartTransaction(request)
}

return conn.StartTransaction(request)
return new(core.StartTransactionConfirmation), nil
}

func (cp *CP) StopTransaction(request *core.StopTransactionRequest) (*core.StopTransactionConfirmation, error) {
if request == nil {
return nil, ErrInvalidRequest
}

conn := cp.connectorByTransactionID(request.TransactionId)
if conn == nil {
res := &core.StopTransactionConfirmation{
IdTagInfo: &types.IdTagInfo{
Status: types.AuthorizationStatusAccepted, // accept old pending stop message during startup
},
}
if conn := cp.connectorByTransactionID(request.TransactionId); conn != nil {
return conn.StopTransaction(request)
}

return res, nil
res := &core.StopTransactionConfirmation{
IdTagInfo: &types.IdTagInfo{
Status: types.AuthorizationStatusAccepted, // accept old pending stop message during startup
},
}

return conn.StopTransaction(request)
return res, nil
}

0 comments on commit 009a9c2

Please sign in to comment.