Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meter values not received #14

Open
solanu opened this issue May 26, 2021 · 0 comments
Open

Meter values not received #14

solanu opened this issue May 26, 2021 · 0 comments

Comments

@solanu
Copy link

solanu commented May 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant