Skip to content

Commit

Permalink
Ocpp: add workarounds for Enercab Smart (ELEDIO - EVCC01) (#13990)
Browse files Browse the repository at this point in the history
* allow enercab smart (ELEDIO / EVCC01) sending file:// and not ip/name as origin string when switching to websocket
* allow enercab smart (ELEDIO / EVCC01) sending space padded numerical values of small numbers
* accept old pending stop message during startup
* Accept stopping unknown txn
  • Loading branch information
franzongit authored Jun 2, 2024
1 parent 72439a5 commit 68cc29a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions charger/ocpp/connector_core.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ocpp

import (
"strings"
"time"

"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
Expand Down Expand Up @@ -60,6 +61,7 @@ func (conn *Connector) MeterValues(request *core.MeterValuesRequest) (*core.Mete
// ignore old meter value requests
if meterValue.Timestamp.Time.After(conn.meterUpdated) {
for _, sample := range meterValue.SampledValue {
sample.Value = strings.TrimSpace(sample.Value)
conn.measurements[getSampleKey(sample)] = sample
conn.meterUpdated = conn.clock.Now()
}
Expand Down
8 changes: 7 additions & 1 deletion charger/ocpp/cp_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ func (cp *CP) StopTransaction(request *core.StopTransactionRequest) (*core.StopT

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

return res, nil
}

return conn.StopTransaction(request)
Expand Down
2 changes: 2 additions & 0 deletions charger/ocpp/instance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ocpp

import (
"net/http"
"sync"
"time"

Expand Down Expand Up @@ -31,6 +32,7 @@ func Instance() *CS {

server := ws.NewServer()
server.SetTimeoutConfig(timeoutConfig)
server.SetCheckOriginHandler(func(r *http.Request) bool { return true })

dispatcher := ocppj.NewDefaultServerDispatcher(ocppj.NewFIFOQueueMap(0))
dispatcher.SetTimeout(time.Minute)
Expand Down
3 changes: 2 additions & 1 deletion charger/ocpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ func (suite *ocppTestSuite) TestConnect() {
{
expectedTxn := 99

// always accept stopping unknown transaction, see https://github.com/evcc-io/evcc/pull/13990
_, err := cp1.StopTransaction(0, types.NewDateTime(suite.clock.Now()), expectedTxn)
suite.Require().Error(err)
suite.Require().NoError(err)

_, err = cp1.MeterValues(1, []types.MeterValue{
{
Expand Down

0 comments on commit 68cc29a

Please sign in to comment.