From cd36be6b10d273f175e6571cc704a29f42166b19 Mon Sep 17 00:00:00 2001 From: Ryan Bright Date: Thu, 30 Nov 2023 08:34:57 -0700 Subject: [PATCH] Add Stop to CSMS and CentralSystem --- ocpp1.6/central_system.go | 4 ++++ ocpp1.6/v16.go | 2 ++ ocpp2.0.1/csms.go | 4 ++++ ocpp2.0.1/v2.go | 2 ++ 4 files changed, 12 insertions(+) diff --git a/ocpp1.6/central_system.go b/ocpp1.6/central_system.go index 2e313776..a7b0c29d 100644 --- a/ocpp1.6/central_system.go +++ b/ocpp1.6/central_system.go @@ -409,6 +409,10 @@ func (cs *centralSystem) Start(listenPort int, listenPath string) { cs.server.Start(listenPort, listenPath) } +func (cs *centralSystem) Stop() { + cs.server.Stop() +} + func (cs *centralSystem) sendResponse(chargePointId string, confirmation ocpp.Response, err error, requestId string) { if err != nil { // Send error response diff --git a/ocpp1.6/v16.go b/ocpp1.6/v16.go index e0fd0ffc..853ec147 100644 --- a/ocpp1.6/v16.go +++ b/ocpp1.6/v16.go @@ -259,6 +259,8 @@ type CentralSystem interface { // The function blocks forever, so it is suggested to wrap it in a goroutine, in case other functionality needs to be executed on the main program thread. Start(listenPort int, listenPath string) + // Stops the central system, clearing all pending requests. + Stop() // Errors returns a channel for error messages. If it doesn't exist it es created. Errors() <-chan error } diff --git a/ocpp2.0.1/csms.go b/ocpp2.0.1/csms.go index eddb0292..0a54442b 100644 --- a/ocpp2.0.1/csms.go +++ b/ocpp2.0.1/csms.go @@ -815,6 +815,10 @@ func (cs *csms) Start(listenPort int, listenPath string) { cs.server.Start(listenPort, listenPath) } +func (cs *csms) Stop() { + cs.server.Stop() +} + func (cs *csms) sendResponse(chargingStationID string, response ocpp.Response, err error, requestId string) { if err != nil { // Send error response diff --git a/ocpp2.0.1/v2.go b/ocpp2.0.1/v2.go index 83953e60..6e58efed 100644 --- a/ocpp2.0.1/v2.go +++ b/ocpp2.0.1/v2.go @@ -390,6 +390,8 @@ type CSMS interface { // The function blocks forever, so it is suggested to wrap it in a goroutine, in case other functionality needs to be executed on the main program thread. Start(listenPort int, listenPath string) + // Stops the CSMS, clearing all pending requests. + Stop() // Errors returns a channel for error messages. If it doesn't exist it es created. Errors() <-chan error }