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:
parent
72439a5774
commit
68cc29a969
4 changed files with 13 additions and 2 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue