Documentation
¶
Overview ¶
Package protocol defines OCPP-J versions, frame types, and payload metadata shared by the CSMS transport and version-specific message packages.
Index ¶
Constants ¶
const ( MaxUniqueIDLength = 36 MaxActionLength = 64 MaxErrorCodeLength = 64 MaxErrorDescriptionLength = 255 )
Variables ¶
var ErrInvalidMessage = errors.New("invalid OCPP message")
Functions ¶
func IsValidationError ¶
IsValidationError reports whether err is a generated OCPP payload constraint violation.
Types ¶
type Call ¶
type Call struct {
ID string
Action string
Payload json.RawMessage
}
func (Call) Type ¶
func (m Call) Type() MessageTypeID
type CallError ¶
type CallError struct {
ID string
Code string
Description string
Details json.RawMessage
}
func (CallError) Type ¶
func (m CallError) Type() MessageTypeID
type CallResult ¶
type CallResult struct {
ID string
Payload json.RawMessage
}
func (CallResult) Type ¶
func (m CallResult) Type() MessageTypeID
func (CallResult) UniqueID ¶
func (m CallResult) UniqueID() string
type Message ¶
type Message interface {
Type() MessageTypeID
UniqueID() string
// contains filtered or unexported methods
}
Message is implemented by the four OCPP-J wire frame types Call, CallResult, CallError, and Send. It is sealed because Encode cannot safely serialize arbitrary external implementations.
type MessageTypeID ¶
type MessageTypeID int
const ( CallType MessageTypeID = 2 CallResultType MessageTypeID = 3 CallErrorType MessageTypeID = 4 SendType MessageTypeID = 6 )
type Payload ¶
type Payload interface {
ActionName() string
Version() Version
Direction() PayloadDirection
SchemaName() string
Validate() error
ValidateJSON([]byte) error
}
Payload is implemented by every generated OCPP request and confirmation. It describes the wire action and version and validates itself against the corresponding official OCPP JSON Schema.
type PayloadDirection ¶
type PayloadDirection uint8
const ( RequestPayload PayloadDirection = iota + 1 ConfirmationPayload )
type Send ¶
type Send struct {
ID string
Action string
Payload json.RawMessage
}
Send is an OCPP 2.1 unconfirmed message. The receiver must not return a CALLRESULT or CALLERROR.
func (Send) Type ¶
func (m Send) Type() MessageTypeID
type UnsupportedMessageTypeError ¶
type UnsupportedMessageTypeError struct {
ID string
Type MessageTypeID
}
func (*UnsupportedMessageTypeError) Error ¶
func (e *UnsupportedMessageTypeError) Error() string
func (*UnsupportedMessageTypeError) Unwrap ¶
func (e *UnsupportedMessageTypeError) Unwrap() error
type Version ¶
type Version string
Version is an OCPP-J WebSocket subprotocol.
func ParseVersion ¶
func SupportedVersions ¶
func SupportedVersions() []Version