go-ocpp
v1.5 and v1.6 Open Charge Point Protocol implementation in Golang.
https://github.com/voltbras/go-ocpp
Category: Consumption
Sub Category: Mobility and Transportation
Keywords
charging-stations chargingstation electric-vehicles emobility ocpp
Last synced: about 2 hours ago
JSON representation
Repository metadata
v1.5 and v1.6 OCPP implementation in Golang
- Host: GitHub
- URL: https://github.com/voltbras/go-ocpp
- Owner: voltbras
- License: gpl-3.0
- Created: 2019-02-20T17:11:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-16T10:02:22.000Z (about 3 years ago)
- Last Synced: 2025-04-10T05:04:46.864Z (17 days ago)
- Topics: charging-stations, chargingstation, electric-vehicles, emobility, ocpp
- Language: Go
- Homepage:
- Size: 187 KB
- Stars: 47
- Watchers: 5
- Forks: 6
- Open Issues: 4
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
go-ocpp
OCPP(1.5/1.6) implementation in Golang.
- v1.5, it's assumed it is SOAP
- v1.6, it's assumed it is JSON
Usage
Central System
Just pass a handler that takes in a cpreq.ChargePointRequest
and returns a (cpresp.ChargePointResponse, error)
.
In SOAP, error messages will be sent back via Fault, as specified in OCPP v1.5
In Websockets, error messages will be sent back as specified in OCPP-J v1.6
csys := cs.New()
go csys.Run(":12811", func(req cpreq.ChargePointRequest, metadata cs.ChargePointRequestMetadata) (cpresp.ChargePointResponse, error) {
// Return an error to the Station communicating to the Central System
//
// station, isAuthorized := getStation(metadata.ChargePointID)
// if !isAuthorized {
// return nil, errors.New("charger not authorized to join network")
// }
// ---
// Or check some specific header in the underlying HTTP request:
//
// if shouldBlock(metadata.HTTPRequest) {
// return nil, errors.New("charger should send appropriate headers")
// }
switch req := req.(type) {
case *cpreq.BootNotification:
// accept chargepoint in the network
return &cpresp.BootNotification{
Status: "Accepted",
CurrentTime: time.Now(),
Interval: 60,
}, nil
case *cpreq.Heartbeat:
return &cpresp.Heartbeat{CurrentTime: time.Now()}, nil
case *cpreq.StatusNotification:
if req.Status != "Available" {
// chargepoint is unavailable
}
return &cpresp.StatusNotification{}, nil
default:
return nil, errors.New("Response not supported")
}
}
Charge Point
Pass the required parameters to the constructor function, and then just send any request(cpreq.*
).
TODO: assertion of the response type should be done inside the .Send
?
stationID := "id01"
centralSystemURL := "ws://localhost:12811"
st, err := cp.NewChargePoint(stationID, centralSystemURL, ocpp.V16, ocpp.JSON, nil, handler) // or ocpp.SOAP
if err != nil {
fmt.Println("could not create charge point:", err)
return
}
rawResp, err := st.Send(&cpreq.Heartbeat{})
if err != nil {
fmt.Println("could't send heartbeat:", err)
return
}
resp, ok := rawResp.(*cpresp.Heartbeat)
if !ok {
fmt.Println("response is not a heartbeat response")
return
}
fmt.Println("got reply:", resp)
Logs
For more useful logging, do:
ocpp.SetDebugLogger(log.New(os.Stdout, "DEBUG:", log.Ltime))
ocpp.SetErrorLogger(log.New(os.Stderr, "ERROR:", log.Ltime))
Owner metadata
- Name: Voltbras
- Login: voltbras
- Email: [email protected]
- Kind: organization
- Description:
- Website: https://voltbras.com.br/
- Location: Florianópolis
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/64649105?v=4
- Repositories: 2
- Last ynced at: 2023-03-10T03:25:26.155Z
- Profile URL: https://github.com/voltbras
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers metadata
Last synced: 6 days ago
Total Commits: 50
Total Committers: 1
Avg Commits per committer: 50.0
Development Distribution Score (DDS): 0.0
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
eduhenke | e****e@h****m | 50 |
Committer domains:
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 10
Total pull requests: 5
Average time to close issues: 3 months
Average time to close pull requests: 4 months
Total issue authors: 8
Total pull request authors: 2
Average comments per issue: 1.8
Average comments per pull request: 0.0
Merged pull request: 4
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- oscarjairIT (2)
- eduhenke (2)
- darkrain (1)
- AlexMartSch (1)
- FlorishL (1)
- EstoyAburrido (1)
- solanu (1)
- michaelbironneau (1)
Top Pull Request Authors
- eduhenke (4)
- hevanto (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
proxy.golang.org: github.com/voltbras/go-ocpp
- Homepage: https://github.com/voltbras/go-ocpp
- Documentation: https://pkg.go.dev/github.com/voltbras/go-ocpp#section-documentation
- Licenses: GPL-3.0
- Latest release: v1.1.0 (published about 4 years ago)
- Last Synced: 2025-04-26T13:00:55.646Z (1 day ago)
- Versions: 3
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.646%
- Forks count: 4.268%
- Average: 6.065%
- Dependent packages count: 6.999%
- Dependent repos count: 9.346%
Dependencies
- github.com/google/uuid v1.1.0
- github.com/gorilla/websocket v1.4.1
- github.com/stretchr/testify v1.6.1
- github.com/davecgh/go-spew v1.1.0
- github.com/google/uuid v1.1.0
- github.com/gorilla/websocket v1.4.1
- github.com/pmezard/go-difflib v1.0.0
- github.com/stretchr/objx v0.1.0
- github.com/stretchr/testify v1.6.1
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
- gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
Score: -Infinity