Code Monkey home page Code Monkey logo

ocmf-go's Introduction

OCMF-go

OCMF-go is an implementation of the Open Charge Metering Format (OCMF) in Go. It provides a simple library for generating and parsing OCMF messages. The provided message builder generates OCMF-compatible messages and signs the data with the provided private key, desired algorithm and encoding, so you don't have to.

Installation

go get github.com/ChargePi/ocmf-go

Usage

package main

import (
	"fmt"

	ocmf_go "github.com/ChargePi/ocmf-go"
	"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
)

func main() {
	// Generate a new message builder
	builder := ocmf_go.NewBuilder()

	// Set the signature algorithm
	builder.SetSignatureAlgorithm(ocmf_go.SignatureAlgorithmECDSAsecp256r1Sha256)

	// Set the signature encoding
	builder.SetSignatureEncoding(ocmf_go.SignatureEncodingBase64)

	// ... set the desired fields
	message, err := builder.Build()
	if err != nil {
		fmt.Println(err)
	}

	// Create a MeterValue message with the generated message as value 
	meterValueExample := types.MeterValue{
		SampledValue: []types.SampledValue{
			{
				Value:  message,
				Format: types.ValueFormatSignedData,
			},
		},
	}

	// Send the message via OCPP 1.5/1.6.
}

Contributing

Contributions are welcome! Please check out the contributing guide for more information.

License

OCMF-go is licensed under the MIT License.

ocmf-go's People

Contributors

xblaz3kx avatar

Stargazers

 avatar

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.