Skip to content

Commit

Permalink
refactor: [LB/RB/AF] lorenzodonini#13 Add StartWithRetries to handle …
Browse files Browse the repository at this point in the history
…retries upon first connection at the ChargingStation interface
  • Loading branch information
alessioerosferri committed Dec 11, 2023
1 parent 33c5505 commit c818125
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ocpp2.0.1/charging_station.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,14 @@ func (cs *chargingStation) Start(csmsUrl string) error {
return err
}

func (cs *chargingStation) StartWithRetries(csmsUrl string) {
// Start client
cs.stopC = make(chan struct{}, 1)
cs.client.StartWithRetries(csmsUrl)
// Async response handler receives incoming responses/errors and triggers callbacks
go cs.asyncCallbackHandler()
}

func (cs *chargingStation) Stop() {
cs.client.Stop()
}
Expand Down
7 changes: 7 additions & 0 deletions ocpp2.0.1/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ type ChargingStation interface {
//
// No auto-reconnect logic is implemented as of now, but is planned for the future.
Start(csmsUrl string) error

// Connects to the CSMS and starts the charging station routine, it retries if first attempt fails.
// The function doesn't block and returns right away, after having attempted to open a connection to the CSMS.
// If the connection couldn't be opened, it retries.
//
// Optional client options must be set before calling this function. Refer to NewChargingStation.
StartWithRetries(csmsUrl string)
// Stops the charging station routine, disconnecting it from the CSMS.
// Any pending requests are discarded.
Stop()
Expand Down

0 comments on commit c818125

Please sign in to comment.