Ocpp: add workarounds for Enercab Smart (ELEDIO - EVCC01) (#13990)

* 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
This commit is contained in:
franzongit 2024-06-02 17:50:43 +02:00 • committed by GitHub
parent 72439a5774
commit 68cc29a969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package ocpp
import (
"strings"
"time"
"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
@ -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()
}

View file

@ -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)

View file

@ -1,6 +1,7 @@
package ocpp
import (
"net/http"
"sync"
"time"
@ -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)

View file

@ -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{
{