Ocpp: make sure central system always responds to chargepoint requests (#16279)
This commit is contained in:
parent
9dc383a897
commit
034b3241f4
1 changed files with 34 additions and 20 deletions
|
|
@ -3,6 +3,7 @@ package ocpp
|
|||
import (
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
|
||||
)
|
||||
|
||||
// cp actions
|
||||
|
|
@ -17,12 +18,17 @@ func (cs *CS) OnAuthorize(id string, request *core.AuthorizeRequest) (*core.Auth
|
|||
}
|
||||
|
||||
func (cs *CS) OnBootNotification(id string, request *core.BootNotificationRequest) (*core.BootNotificationConfirmation, error) {
|
||||
cp, err := cs.ChargepointByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if cp, err := cs.ChargepointByID(id); err == nil {
|
||||
return cp.OnBootNotification(request)
|
||||
}
|
||||
|
||||
return cp.OnBootNotification(request)
|
||||
res := &core.BootNotificationConfirmation{
|
||||
CurrentTime: types.Now(),
|
||||
Interval: 60,
|
||||
Status: core.RegistrationStatusPending, // not accepted during startup
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnDataTransfer(id string, request *core.DataTransferRequest) (*core.DataTransferConfirmation, error) {
|
||||
|
|
@ -44,39 +50,47 @@ func (cs *CS) OnHeartbeat(id string, request *core.HeartbeatRequest) (*core.Hear
|
|||
}
|
||||
|
||||
func (cs *CS) OnMeterValues(id string, request *core.MeterValuesRequest) (*core.MeterValuesConfirmation, error) {
|
||||
cp, err := cs.ChargepointByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if cp, err := cs.ChargepointByID(id); err == nil {
|
||||
return cp.OnMeterValues(request)
|
||||
}
|
||||
|
||||
return cp.OnMeterValues(request)
|
||||
return new(core.MeterValuesConfirmation), nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnStatusNotification(id string, request *core.StatusNotificationRequest) (*core.StatusNotificationConfirmation, error) {
|
||||
cp, err := cs.ChargepointByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if cp, err := cs.ChargepointByID(id); err == nil {
|
||||
return cp.OnStatusNotification(request)
|
||||
}
|
||||
|
||||
return cp.OnStatusNotification(request)
|
||||
return new(core.StatusNotificationConfirmation), nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnStartTransaction(id string, request *core.StartTransactionRequest) (*core.StartTransactionConfirmation, error) {
|
||||
cp, err := cs.ChargepointByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if cp, err := cs.ChargepointByID(id); err == nil {
|
||||
return cp.OnStartTransaction(request)
|
||||
}
|
||||
|
||||
return cp.OnStartTransaction(request)
|
||||
res := &core.StartTransactionConfirmation{
|
||||
IdTagInfo: &types.IdTagInfo{
|
||||
Status: types.AuthorizationStatusAccepted,
|
||||
},
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnStopTransaction(id string, request *core.StopTransactionRequest) (*core.StopTransactionConfirmation, error) {
|
||||
cp, err := cs.ChargepointByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if cp, err := cs.ChargepointByID(id); err == nil {
|
||||
cp.OnStopTransaction(request)
|
||||
}
|
||||
|
||||
return cp.OnStopTransaction(request)
|
||||
res := &core.StopTransactionConfirmation{
|
||||
IdTagInfo: &types.IdTagInfo{
|
||||
Status: types.AuthorizationStatusAccepted, // accept old pending stop message during startup
|
||||
},
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnDiagnosticsStatusNotification(id string, request *firmware.DiagnosticsStatusNotificationRequest) (confirmation *firmware.DiagnosticsStatusNotificationConfirmation, err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue