Documentation
¶
Overview ¶
Package ocppj implements OCPP-J (JSON over WebSocket) framing.
Index ¶
- Variables
- func EncodeCall(msgID, action string, payload []byte) ([]byte, error)
- func EncodeCallError(msgID, code, desc string, details []byte) ([]byte, error)
- func EncodeCallResult(msgID string, payload []byte) ([]byte, error)
- func NewMsgID() string
- type CallError
- type Direction
- type ErrorCode
- type Frame
- type Message
- type MessageType
- type ProtocolError
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( ErrConnClosed = errors.New("ocpp: connection closed") ErrConnDropped = errors.New("ocpp: connection dropped") ErrNotConnected = errors.New("ocpp: not connected") ErrAlreadyConnected = errors.New("ocpp: already connected") ErrCallTimeout = errors.New("ocpp: call timeout") ErrCallCancelled = errors.New("ocpp: call cancelled") ErrQueueFull = errors.New("ocpp: outbound queue full") ErrConcurrentCallLimit = errors.New("ocpp: concurrent call limit exceeded") ErrUnknownAction = errors.New("ocpp: unknown action") ErrHandlerNotRegistered = errors.New("ocpp: handler not registered") ErrInvalidDirection = errors.New("ocpp: invalid message direction") ErrDuplicateHandler = errors.New("ocpp: handler already registered") ErrUnsupportedVersion = errors.New("ocpp: unsupported version") ErrVersionMismatch = errors.New("ocpp: version mismatch on connection") )
Functions ¶
func EncodeCall ¶
EncodeCall builds a [2, msgID, action, payload] frame.
func EncodeCallError ¶
EncodeCallError builds a [4, msgID, code, desc, details] frame.
func EncodeCallResult ¶
EncodeCallResult builds a [3, msgID, payload] frame.
Types ¶
type CallError ¶
type CallError struct {
Code ErrorCode
Description string
Details map[string]any
// contains filtered or unexported fields
}
CallError is an OCPP-J error response (MessageType 4).
func NewCallError ¶
NewCallError builds a CallError.
func WrapCallError ¶
WrapCallError builds a CallError wrapping an underlying cause.
type ErrorCode ¶
type ErrorCode string
ErrorCode is an OCPP-J CallError code.
const ( ErrorCodeNotImplemented ErrorCode = "NotImplemented" ErrorCodeNotSupported ErrorCode = "NotSupported" ErrorCodeInternalError ErrorCode = "InternalError" ErrorCodeProtocolError ErrorCode = "ProtocolError" ErrorCodeSecurityError ErrorCode = "SecurityError" ErrorCodeFormatViolation ErrorCode = "FormatViolation" // 2.x ErrorCodeFormationViolation ErrorCode = "FormationViolation" // 1.6 ErrorCodePropertyConstraintViolation ErrorCode = "PropertyConstraintViolation" ErrorCodeOccurenceConstraintViolation ErrorCode = "OccurenceConstraintViolation" //nolint:misspell // OCPP 1.6 spec wire spelling ErrorCodeOccurrenceConstraintViolation ErrorCode = "OccurrenceConstraintViolation" // 2.x ErrorCodeTypeConstraintViolation ErrorCode = "TypeConstraintViolation" ErrorCodeGenericError ErrorCode = "GenericError" ErrorCodeMessageTypeNotSupported ErrorCode = "MessageTypeNotSupported" // 2.x ErrorCodeRPCFrameworkError ErrorCode = "RpcFrameworkError" // 2.x )
type Frame ¶
type Frame struct {
Type MessageType
MsgID string
Action string // Call only
Payload []byte // Call / CallResult: raw JSON object
ErrCode string // CallError only
ErrDesc string // CallError only
ErrData []byte // CallError only: raw JSON object
}
Frame is a parsed OCPP-J message.
type Message ¶
Message binds an OCPP action to its request and response types at compile time. Generated code creates package-level Message values; user code passes them to On/Call so Req/Resp are inferred.
type MessageType ¶
type MessageType int
MessageType is the OCPP-J MessageTypeId (first array element).
const ( Call MessageType = 2 CallResult MessageType = 3 MessageTypeCallError MessageType = 4 )
func (MessageType) String ¶
func (m MessageType) String() string
type ProtocolError ¶
ProtocolError indicates an OCPP-J frame that does not conform to the wire format.
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string