Documentation
¶
Overview ¶
Package cp implements the OCPP Charge Point (client) side.
Index ¶
- func Call[Req, Resp any](ctx context.Context, c *Client, m ocppj.Message[Req, Resp], req Req) (Resp, error)
- func CallRaw(ctx context.Context, c *Client, action string, payload []byte) ([]byte, error)
- func On[Req, Resp any](c *Client, m ocppj.Message[Req, Resp], ...) error
- type Client
- type Option
- func WithCallTimeout(d time.Duration) Option
- func WithHeartbeatInterval(d time.Duration) Option
- func WithLogger(l *slog.Logger) Option
- func WithSchemaRegistry(r *schema.Registry) Option
- func WithStrictSchema(strict bool) Option
- func WithSubProtocols(p ...string) Option
- func WithTolerantSchema() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
func Call[Req, Resp any](ctx context.Context, c *Client, m ocppj.Message[Req, Resp], req Req) (Resp, error)
Call sends a typed message from this charge point to the CSMS.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an OCPP charge point.
func (*Client) IsConnected ¶
IsConnected reports whether a live connection exists.
func (*Client) NegotiatedProtocol ¶
NegotiatedProtocol returns the subprotocol chosen during the handshake.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Client.
func WithCallTimeout ¶
WithCallTimeout sets the per-call timeout.
func WithHeartbeatInterval ¶
WithHeartbeatInterval sets the OCPP Heartbeat interval.
func WithSchemaRegistry ¶
WithSchemaRegistry sets the schema registry used for first-layer validation.
func WithStrictSchema ¶
WithStrictSchema controls whether schema validation failures reject the message. Passing false turns schema validation off. If WithStrictSchema and WithTolerantSchema are both used, the last option in the list wins.
func WithSubProtocols ¶
WithSubProtocols sets offered subprotocols.
func WithTolerantSchema ¶
func WithTolerantSchema() Option
WithTolerantSchema enables schema validation that logs validation failures but continues processing messages. If WithStrictSchema and WithTolerantSchema are both used, the last option in the list wins.