OCPP: Handle security events silently (#23199)
This commit is contained in:
parent
5272052fee
commit
ab2f706b46
2 changed files with 23 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package ocpp
|
|||
|
||||
import (
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/security"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
|
||||
)
|
||||
|
||||
|
|
@ -105,3 +106,22 @@ func (cs *CS) OnStopTransaction(id string, request *core.StopTransactionRequest)
|
|||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnSecurityEventNotification(id string, request *security.SecurityEventNotificationRequest) (*security.SecurityEventNotificationResponse, error) {
|
||||
// Acknowledge any security event
|
||||
return &security.SecurityEventNotificationResponse{}, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnSignCertificate(id string, request *security.SignCertificateRequest) (*security.SignCertificateResponse, error) {
|
||||
// Reject any certificate signing request
|
||||
return &security.SignCertificateResponse{
|
||||
Status: types.GenericStatusRejected,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (cs *CS) OnCertificateSigned(id string, request *security.CertificateSignedRequest) (*security.CertificateSignedResponse, error) {
|
||||
// Acknowledge any certificate
|
||||
return &security.CertificateSignedResponse{
|
||||
Status: security.CertificateSignedStatusAccepted,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
ocpp16 "github.com/lorenzodonini/ocpp-go/ocpp1.6"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/remotetrigger"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/security"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
|
||||
"github.com/lorenzodonini/ocpp-go/ocppj"
|
||||
"github.com/lorenzodonini/ocpp-go/ws"
|
||||
|
|
@ -30,7 +31,7 @@ func Instance() *CS {
|
|||
dispatcher := ocppj.NewDefaultServerDispatcher(ocppj.NewFIFOQueueMap(0))
|
||||
dispatcher.SetTimeout(Timeout)
|
||||
|
||||
endpoint := ocppj.NewServer(server, dispatcher, nil, core.Profile, remotetrigger.Profile, smartcharging.Profile)
|
||||
endpoint := ocppj.NewServer(server, dispatcher, nil, core.Profile, remotetrigger.Profile, smartcharging.Profile, security.Profile)
|
||||
endpoint.SetInvalidMessageHook(func(client ws.Channel, err *ocpp.Error, rawMessage string, parsedFields []interface{}) *ocpp.Error {
|
||||
log.ERROR.Printf("%v (%s)", err, rawMessage)
|
||||
return nil
|
||||
|
|
@ -49,6 +50,7 @@ func Instance() *CS {
|
|||
ocppj.SetLogger(instance)
|
||||
|
||||
cs.SetCoreHandler(instance)
|
||||
cs.SetSecurityHandler(instance)
|
||||
cs.SetNewChargePointHandler(instance.NewChargePoint)
|
||||
cs.SetChargePointDisconnectedHandler(instance.ChargePointDisconnected)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue