Giter VIP home page Giter VIP logo

go-ocpp's People

Contributors

eduhenke avatar gustavomedeiross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-ocpp's Issues

Add security layer with identification of MAC address

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!

Too much goroutine

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?

.Send method does not omit empty values at is should

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 ?

Auto-Reconnect

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

  • We have a golang program running (with your files).
  • We know that the machine auto reconnect on "Hard Reset".
  • We know that the machine NO auto reconnect if the LAN cable is removed and put it again. (Simulating a Wi-Fi connection with an interference or micro cuts)

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.

Can't send DataTransfer command

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

Module declares inconsistent path

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.

Simplify usage of the CS/CP Service Send

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:

  • Do the type assertion inside the .Send, and outside the function just ignore the type assertion "ok"
  • Implement a Send{Heartbeat,RemoteStartTransaction,...} for every request/response pair, easier for the user to use, as it does not require type assertion, and the response given back is exactly the expected. However it duplicates a lot of code(though this lib does that a lot in the (cp/cs)(req/res) packages)

Usage of ReadMessage() eats high amount of memory

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?.

Meter values not received

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.

GetServiceOf Method always received csys.conns map data Null

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.