@@ -307,6 +307,56 @@ Then run the following:
307307docker-compose -f example/1.6/docker-compose.tls.yml up charge-point
308308```
309309
310+ ## Advanced Features
311+
312+ The library offers several advanced features, especially at websocket and ocpp-j level.
313+
314+ ### Automatic message validation
315+
316+ All incoming and outgoing messages are validated by default, using the [ validator] ( gopkg.in/go-playground/validator ) package.
317+ Constraints are defined on every request/response struct, as per OCPP specs.
318+
319+ Validation may be disabled at a package level if needed:
320+ ``` go
321+ ocppj.SetMessageValidation (false )
322+ ```
323+
324+ Use at your own risk, as this will disable validation for all messages!
325+
326+ > I will be evaluating the possibility to selectively disable validation for a specific message,
327+ > e.g. by passing message options.
328+
329+ ### Verbose logging
330+
331+ The ` ws ` and ` ocppj ` packages offer the possibility to enable verbose logs, via your logger of choice, e.g.:
332+ ``` go
333+ // Setup your own logger
334+ log = logrus.New ()
335+ log.SetFormatter (&logrus.TextFormatter {FullTimestamp: true })
336+ log.SetLevel (logrus.DebugLevel ) // Debug level needed to see all logs
337+ // Pass own logger to ws and ocppj packages
338+ ws.SetLogger (log.WithField (" logger" , " websocket" ))
339+ ocppj.SetLogger (log.WithField (" logger" , " ocppj" ))
340+ ```
341+ The logger you pass needs to conform to the ` logging.Logger ` interface.
342+ Commonly used logging libraries, such as zap or logrus, adhere to this interface out-of-the-box.
343+
344+ 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.
345+
346+ ### Websocket ping-pong
347+
348+ The websocket package currently supports client-initiated pings only.
349+
350+ If your setup requires the server to be the initiator of a ping-pong (e.g. for web-based charge points),
351+ you may disable ping-pong entirely and just rely on the heartbeat mechanism:
352+ ``` go
353+ cfg := ws.NewServerTimeoutConfig ()
354+ cfg.PingWait = 0 // this instructs the server to wait forever
355+ websocketServer.SetTimeoutConfig (cfg)
356+ ```
357+
358+ > A server-initiated ping may be supported in a future release.
359+
310360## OCPP 2.0 Usage
311361
312362Documentation will follow, once the protocol is fully implemented.
0 commit comments