ocpp

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V15 = Version("1.5")
	V16 = Version("1.6")
	V20 = Version("2.0")
	V21 = Version("2.1")
)

Variables

This section is empty.

Functions

func IsErrorCodeValid

func IsErrorCodeValid(code ErrorCode) bool

func IsValidProtocolVersion

func IsValidProtocolVersion(version Version) bool

Types

type Call

type Call struct {
	MessageTypeId MessageType `json:"messageTypeId" validate:"required,eq=2"`
	UniqueId      string      `json:"uniqueId" validate:"required,max=36"`
	Action        string      `json:"action" validate:"required,max=36"`
	Payload       interface{} `json:"payload" validate:"required"`
}

An OCPP-J Call message, containing an OCPP Request.

func (*Call) GetAction

func (call *Call) GetAction() string

func (*Call) GetMessageTypeId

func (call *Call) GetMessageTypeId() MessageType

func (*Call) GetPayload

func (call *Call) GetPayload() interface{}

func (*Call) GetUniqueId

func (call *Call) GetUniqueId() string

type CallError

type CallError struct {
	MessageTypeId    MessageType `json:"messageTypeId"`
	UniqueId         string      `json:"uniqueId"`
	ErrorCode        ErrorCode   `json:"errorCode"`
	ErrorDescription string      `json:"errorDescription"`
	ErrorDetails     interface{} `json:"errorDetails"`
}

An OCPP-J CallError message, containing an OCPP Error.

func (*CallError) GetAction

func (callError *CallError) GetAction() string

func (*CallError) GetMessageTypeId

func (callError *CallError) GetMessageTypeId() MessageType

func (*CallError) GetPayload

func (callError *CallError) GetPayload() interface{}

func (*CallError) GetUniqueId

func (callError *CallError) GetUniqueId() string

type CallResult

type CallResult struct {
	MessageTypeId MessageType `json:"messageTypeId"`
	UniqueId      string      `json:"uniqueId"`
	Payload       interface{} `json:"payload"`
	Action        string      `json:"action"`
}

An OCPP-J CallResult message, containing an OCPP Response.

func (*CallResult) GetAction

func (callResult *CallResult) GetAction() string

func (*CallResult) GetMessageTypeId

func (callResult *CallResult) GetMessageTypeId() MessageType

func (*CallResult) GetPayload

func (callResult *CallResult) GetPayload() interface{}

func (*CallResult) GetUniqueId

func (callResult *CallResult) GetUniqueId() string

type CallResultError added in v0.4.0

type CallResultError struct {
	Message
	MessageTypeId    MessageType `json:"messageTypeId" validate:"required,eq=5"`
	UniqueId         string      `json:"uniqueId" validate:"required,max=36"`
	ErrorCode        ErrorCode   `json:"errorCode" validate:"errorCode"`
	ErrorDescription string      `json:"errorDescription" validate:"omitempty,max=255"`
	ErrorDetails     interface{} `json:"errorDetails" validate:"omitempty"`
}

An OCPP-J CallResultError message, containing an OCPP Result Error.

func (*CallResultError) GetAction added in v0.4.0

func (callError *CallResultError) GetAction() string

func (*CallResultError) GetMessageTypeId added in v0.4.0

func (callError *CallResultError) GetMessageTypeId() MessageType

func (*CallResultError) GetPayload added in v0.4.0

func (callError *CallResultError) GetPayload() interface{}

func (*CallResultError) GetUniqueId added in v0.4.0

func (callError *CallResultError) GetUniqueId() string

type ErrorCode

type ErrorCode string
const (
	NotImplemented                   ErrorCode = "NotImplemented"                // Requested Action is not known by receiver.
	NotSupported                     ErrorCode = "NotSupported"                  // Requested Action is recognized but not supported by the receiver.
	InternalError                    ErrorCode = "InternalError"                 // An internal error occurred and the receiver was not able to process the requested Action successfully.
	MessageTypeNotSupported          ErrorCode = "MessageTypeNotSupported"       // A message with a Message Type Number received that is not supported by this implementation.
	ProtocolError                    ErrorCode = "ProtocolError"                 // Payload for Action is incomplete.
	SecurityError                    ErrorCode = "SecurityError"                 // During the processing of Action a security issue occurred preventing receiver from completing the Action successfully.
	PropertyConstraintViolation      ErrorCode = "PropertyConstraintViolation"   // Payload is syntactically correct but at least one field contains an invalid value.
	OccurrenceConstraintViolationV2  ErrorCode = "OccurrenceConstraintViolation" // Payload for Action is syntactically correct but at least one of the fields violates occurrence constraints.
	OccurrenceConstraintViolationV16 ErrorCode = "OccurenceConstraintViolation"  // Payload for Action is syntactically correct but at least one of the fields violates occurrence constraints. Contains a typo in OCPP 1.6
	TypeConstraintViolation          ErrorCode = "TypeConstraintViolation"       // Payload for Action is syntactically correct but at least one of the fields violates data type constraints (e.g. “somestring”: 12).
	GenericError                     ErrorCode = "GenericError"                  // Any other error not covered by the previous ones.
	FormatViolationV2                ErrorCode = "FormatViolation"               // Payload for Action is syntactically incorrect. This is only valid for OCPP 2.0.1
	FormatViolationV16               ErrorCode = "FormationViolation"            // Payload for Action is syntactically incorrect or not conform the PDU structure for Action. This is only valid for OCPP 1.6
)

func FormatErrorType

func FormatErrorType(version Version) ErrorCode

func OccurrenceConstraintErrorType

func OccurrenceConstraintErrorType(version Version) ErrorCode

type Message

type Message interface {
	// Returns the message type identifier of the message.
	GetMessageTypeId() MessageType
	GetPayload() interface{}
	GetAction() string
	GetUniqueId() string
}

An OCPP-J message.

type MessageType

type MessageType int

MessageType identifies the type of message exchanged between two OCPP endpoints.

const (
	CALL              MessageType = 2
	CALL_RESULT       MessageType = 3
	CALL_ERROR        MessageType = 4
	CALL_RESULT_ERROR MessageType = 5
	SEND              MessageType = 6
)

type OcppContext added in v0.6.0

type OcppContext struct {
	Version Version // Required
	Vendor  string  // Optional. Must be present if model is set.
	Model   string  // Optional.
}

OcppContext carries the OCPP protocol version together with optional vendor and model identifiers used for vendor/model-specific schema selection.

type Send added in v0.4.0

type Send struct {
	Message       `validate:"-"`
	MessageTypeId MessageType `json:"messageTypeId" validate:"required,eq=6"`
	UniqueId      string      `json:"uniqueId" validate:"required,max=36"`
	Action        string      `json:"action" validate:"required,max=36"`
	Payload       interface{} `json:"payload" validate:"required"`
}

An OCPP-J SEND message, containing an OCPP Request.

func (*Send) GetAction added in v0.4.0

func (send *Send) GetAction() string

func (*Send) GetMessageTypeId added in v0.4.0

func (send *Send) GetMessageTypeId() MessageType

func (*Send) GetPayload added in v0.4.0

func (send *Send) GetPayload() interface{}

func (*Send) GetUniqueId added in v0.4.0

func (send *Send) GetUniqueId() string

type Version

type Version string

Version OCPP version of the central system or charge point

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL