voltbras / go-ocpp Goto Github PK
View Code? Open in Web Editor NEWv1.5 and v1.6 OCPP implementation in Golang
License: GNU General Public License v3.0
v1.5 and v1.6 OCPP implementation in Golang
License: GNU General Public License v3.0
Hello Eduhenke, thanks for this great contribution. I'm starting with go and OCPP, and I would like to add some security feature with the addittion of the identification of the MAC address of the CP, is there any instance where to get this info?
Thanks in advanced!
Hello! Some times i get this erros on the cs
goroutine 68858 [chan send, 1930 minutes]:
github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync.func1(0xc00248b3e0, 0xc00080a640)
/go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:170 +0x57
created by github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync
/go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:169 +0x65
goroutine 68884 [chan send, 1930 minutes]:
github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync.func1(0xc00256a9c0, 0xc00042f500)
/go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:170 +0x57
created by github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync
/go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:169 +0x65
goroutine 68921 [chan send, 1930 minutes]:
github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync.func1(0xc0025339e0, 0xc00080b500)
/go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:170 +0x57
created by github.com/voltbras/go-ocpp/ws.(*Conn).ReadMessageAsync
^C /go/pkg/mod/github.com/voltbras/[email protected]/ws/conn.go:169 +0x65
Have any idea?
Hi. I'm trying to send a request as follows:
rawResp, err := st.Send(&cpreq.StopTransaction{
TransactionId: ocppVars.TransactionId[id],
MeterStop: int(ocppVars.Connectors[id].Consumed),
Timestamp: time.Now(),
Reason: "Remote",
})
And StopTransaction struct has 'omitempty' json parameters on each non-required field but when I send the request the server(which is not based on the same library) gets this:
"StopTransaction",{"idTag":"","meterStop":13740,"reason":"Remote","timestamp":"2020-12-03T20:41:33+03:00","transactionData":null,"transactionId":1}
It complains about transactionData and replying with the following error message:
Error: Invalid value "null" for field transactionData
As you can see all the other optional fields are also included in the query.
Any idea how do I send the request omitting optional values ?
Hello again!
This time I come with a new question, something related with reconnect with the machine.
I explain you... we have a machine connected by LAN (testing environment).
My solution?
I know that when the machine is disconnected from LAN, in console appears a message -- DEBUG: 18:01:10 Closed connection of: EFA06705
-- I'm thinking in capture the message and exec a function of reconnection, somehow remove go-routines or restart the program for reconnect with the machine.
Yes, is a rustic solution, but I don't know how is it the best solution.
Thanks in advance.
Currently, the DataTransfer command is not working, as the way we parse incoming requests/responses, rely on the action name. And as there are 2 DataTransfer actions: 1 CP->CS, the other CS->CP, we currently can't parse this action
When adding the project to a go module by running go dep init && go get -v github.com/voltbras/go-ocpp
, there is an error:
go: github.com/voltbras/go-ocpp upgrade => v1.0.0
go get: github.com/voltbras/[email protected]: parsing go.mod:
module declares its path as: github.com/eduhenke/go-ocpp
but was required as: github.com/voltbras/go-ocpp
I think the fix is a simple change to your go.mod
file replacing github.com/eduhenke/go-ocpp
by github.com/voltbras/go-ocpp
in the first line.
Happy to submit a PR if you prefer.
Currently, after sending the request(either a cpreq or a csreq), you get back a cpres/csres and an error.
To convert this cpres/csres back to the response type of the requested type, you have to do a type assertion, that consumes more 5 lines.
Solution ideas:
Hello, first of all, I would like to say thanks for the great job of this tool. I get an issue about optimization of memory, I'm getting like 30 cp connections currently, and each one send messages to the cs like 10 messages per minute, so in just 1 hour I get like 10 GB of ram usage ...The problem seems to be the allocation of memory with the ReadMessage method of gorilla/websocket. I've been reading about the high usage of memory with gorilla websocket, and the problem it's solved when change the usage of ReadMessage helper to NextReader function, calling NextReader directly and passing the preallocated buffer to the Read method, but I don't know how implement this one to the ReadMessage() function on ws/conn.go file. Any idea? or future or actual missed implementation?.
I have the following code and I don't receive meter values:
package main
import (
"errors"
"fmt"
"log"
"os"
"strings"
"time"
"github.com/voltbras/go-ocpp"
"github.com/voltbras/go-ocpp/cs"
"github.com/voltbras/go-ocpp/messages/v1x/cpreq"
"github.com/voltbras/go-ocpp/messages/v1x/cpresp"
)
func main() {
ocpp.SetDebugLogger(log.New(os.Stdout, "DEBUG:", log.Ltime))
ocpp.SetErrorLogger(log.New(os.Stderr, "ERROR:", log.Ltime))
csys := cs.New()
go csys.Run(":21022", func(req cpreq.ChargePointRequest, metadata cs.ChargePointRequestMetadata) (cpresp.ChargePointResponse, error) {
fmt.Printf("EXAMPLE(MAIN): Request from %s\n", metadata.ChargePointID)
fmt.Printf(">>>>>>> %v\n", req.Action())
switch req := req.(type) {
case *cpreq.BootNotification:
return &cpresp.BootNotification{
Status: "Accepted",
CurrentTime: time.Now(),
Interval: 60,
}, nil
case *cpreq.Heartbeat:
return &cpresp.Heartbeat{CurrentTime: time.Now()}, nil
case *cpreq.MeterValues:
fmt.Println("This message is not displayed")
fmt.Printf("METADATA %#v\n", metadata)
fmt.Printf("REQ - metervalue: %#v\n", req.MeterValue)
return &cpresp.MeterValues{}, nil
case *cpreq.StatusNotification:
fmt.Println("This works " + req.Status)
if req.Status != "Available" {
// chargepoint is unavailable
}
return &cpresp.StatusNotification{}, nil
default:
fmt.Printf("EXAMPLE(MAIN): action not supported: %s\n", req.Action())
return nil, errors.New("Response not supported")
}
})
select {}
}
My charge point is configure to send meter values.
Hi @eduhenke
appreciated your hard work and effort for this lib but could you please look this method , It seems to me that this method cannot get a value of csys.conns
func (csys *centralSystem) GetServiceOf(cpID string, version ocpp.Version, url string) (service.ChargePoint, error) {
log.Debug("Current WS connections in service map : %v", csys.conns)
log.Debug("Current WS connections in service map : %v", csys.conns[cpID])
if version == ocpp.V15 {
return service.NewChargePointSOAP(url, &soap.CallOptions{
ChargeBoxIdentity: cpID,
// TODO: insert IP address
// From: ,
}), nil
}
if version == ocpp.V16 {
conn := csys.conns[cpID]
if conn == nil { // TODO: or conn closed
return nil, errors.New("no connection to this charge point")
}
return service.NewChargePointJSON(conn), nil
}
return nil, errors.New("charge point has no configured OCPP version(1.5/1.6)")
}
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.