百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
O

ocpp-go

> 编程语言
开源

Go 中的 Open Charge Point Protocol 实现

368 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Go 中的 Open Charge Point Protocol 实现

ocpp-go

Open Charge Point Protocol implementation in Go.

The library targets modern charge points and central systems, running OCPP version 1.6+.

Given that SOAP will no longer be supported in future versions of OCPP, only OCPP-J is supported in this library. There are currently no plans of supporting OCPP-S.

Installation

Go version 1.13+ is required.

bash
go get github.com/lorenzodonini/ocpp-go

You will also need to fetch some dependencies:

bash
cd 
export GO111MODULE=on
go mod download

Your application may either act as a Central System (server) or as a Charge Point (client).

Features and supported versions

Note: Releases 0.10.0 introduced breaking changes in some API, due to refactoring. The functionality remains the same, but naming changed.

Roadmap

Planned milestones and features:

  • Dedicated package for configuration management

Supported versions

  • OCPP 1.6 (documentation available here)
  • OCPP 1.6 Security extension (documentation available here)
  • OCPP 2.0.1 (examples working, but will need more real-world testing) (documentation available here)

Features

The library offers several advanced features, especially at websocket and ocpp-j level.

Automatic message validation

All incoming and outgoing messages are validated by default, using the validator package. Constraints are defined on every request/response struct, as per OCPP specs.

Validation may be disabled at a package level if needed:

go
ocppj.SetMessageValidation(false)

Use at your own risk, as this will disable validation for all messages!

I will be evaluating the possibility to selectively disable validation for a specific message, e.g. by passing message options.

Verbose logging

The ws and ocppj packages offer the possibility to enable verbose logs, via your logger of choice, e.g.:

go
// Setup your own logger
log = logrus.New()
log.SetFormatter(&logrus.TextFormatter{FullTimestamp: true})
log.SetLevel(logrus.DebugLevel) // Debug level needed to see all logs
// Pass own logger to ws and ocppj packages
ws.SetLogger(log.WithField("logger", "websocket"))
ocppj.SetLogger(log.WithField("logger", "ocppj"))

The logger you pass needs to conform to the logging.Logger interface. Commonly used logging libraries, such as zap or logrus, adhere to this interface out-of-the-box.

If you are using a logger, that isn't conform, you can simply write an adapter between the Logger interface and your own logging system.

Websocket ping-pong

The websocket package supports configuring ping pong for both endpoints.

By default, the client sends a ping every 54 seconds and waits for a pong for 60 seconds, before timing out. The values can be configured as follows:

go
cfg := ws.NewClientTimeoutConfig()
cfg.PingPeriod = 10 * time.Second
cfg.PongWait = 20 * time.Second
websocketClient.SetTimeoutConfig(cfg)

By default, the server does not send out any pings and waits for a ping from the client for 60 seconds, before timing out. To configure the server to send out pings, the PingPeriod and PongWait must be set to a value greater than 0:

go
cfg := ws.NewServerTimeoutConfig()
cfg.PingPeriod = 10 * time.Second
cfg.PongWait = 20 * time.Second
websocketServer.SetTimeoutConfig(cfg)

To disable sending ping messages, set the PingPeriod value to 0.

Contributing

Contributions are welcome! Please refer to the testing guide for instructions on how to run the tests.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gocharging-stationselectric-vehiclesemobilityocpp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言