Reference

Contents

Index

OCPPData.AbstractOCPPSpecType

Abstract base type for OCPP protocol version specifiers.

Concrete subtypes (V16.Spec, V201.Spec) are used as dispatch tokens to select version-specific behaviour — e.g. validate(V16.Spec(), ...).

source
OCPPData.OCPPMessageType

OCPP-J message framing types.

The OCPP-J protocol uses JSON arrays with a message type ID as the first element:

  • [2, unique_id, action, payload] → Call
  • [3, unique_id, payload] → CallResult
  • [4, uniqueid, errorcode, desc, det] → CallError
source
OCPPData._build_all_exprsMethod
_build_all_exprs(enums, sorted_types, action_schemas, resolve_type_fn, registry_name)

Shared codegen: emit enum AST, struct AST for sub-types, struct AST for action payloads, and registry AST. Both macros funnel into this.

source
OCPPData._def_to_julia_nameMethod

Derive a Julia type name from a v201 definition name. "BootReasonEnumType" → :BootReason, "ChargingStationType" → :ChargingStation

source
OCPPData._enum_prefixMethod

Derive an enum member prefix from a v201 definition name. "RegistrationStatusEnumType" → "Registration" "BootReasonEnumType" → "BootReason"

source
OCPPData._load_all_schemas!Method
_load_all_schemas!(schemas, schema_dir, actions, filename_fn)

Eagerly load all JSON schemas for a given OCPP version into schemas.

Iterates every action in actions and both message types (:request, :response), reads the JSON file, and stores the parsed JSONSchema.Schema.

source
OCPPData._resolve_typeMethod
_resolve_type(prop, lookup_fn) -> Symbol or Expr

Resolve a JSON schema property to a Julia type expression. lookup_fn(prop) handles version-specific lookups (inline enums, nested types, $ref); shared primitive/array/object logic lives here.

source
OCPPData._topo_sortMethod
_topo_sort(deps_fn, items) -> Vector

Topologically sort items so that dependencies (returned by deps_fn(item)) come before dependents. Falls back to sorted order for cycles.

source
OCPPData.decodeMethod
decode(raw::String)::OCPPMessage

Decode a raw OCPP-J JSON string into the appropriate OCPPMessage subtype. Dispatches on the first element (message type ID): 2=Call, 3=CallResult, 4=CallError.

source
OCPPData.encodeMethod
encode(msg::CallError)::String

Encode a CallError to OCPP-J JSON array format: [4, unique_id, error_code, error_description, error_details].

source
OCPPData.encodeMethod
encode(msg::CallResult)::String

Encode a CallResult to OCPP-J JSON array format: [3, unique_id, payload].

source
OCPPData.encodeMethod
encode(msg::Call)::String

Encode a Call message to OCPP-J JSON array format: [2, unique_id, action, payload].

source
OCPPData.extract_fieldsMethod
extract_fields(schema, resolve_type_fn) -> Vector{FieldDef}

Extract field definitions from a JSON schema. resolve_type_fn(prop, name) maps each property to a Julia type — this is the single point of variation between V16 and V201.

source
OCPPData.read_schemasMethod
read_schemas(schema_dir::String) -> Dict{String, Any}

Read all JSON schema files from a directory. Returns a Dict mapping schema title (e.g. "BootNotificationRequest") to parsed schema.

source
OCPPData.validateMethod
validate(spec::AbstractOCPPSpec, action::String, payload::AbstractDict, msg_type::Symbol)

Validate an OCPP message payload against its JSON schema.

Returns nothing if the payload is valid, or a diagnostic string describing the validation error.

Arguments

  • spec: Version spec instance — V16.Spec() or V201.Spec()
  • action: Action name (e.g., "BootNotification")
  • payload: The message payload as a Dict
  • msg_type: :request or :response

Examples

result = validate(V16.Spec(), "BootNotification", payload, :request)
isnothing(result)  # true if valid

result = validate(V201.Spec(), "BootNotification", payload, :response)
isnothing(result)  # true if valid
source
OCPPData.walk_propertiesMethod
walk_properties(fn, props)

Recursively walk JSON schema properties, calling fn(name, prop) for each. Descends into nested objects and array items that are objects.

source
OCPPData.@generate_ocpp_typesMacro
@generate_ocpp_types schema_dir enum_registry nested_type_names registry_name

Read V16-style OCPP JSON schemas at macro-expansion time and splice all enum, struct, and registry definitions into the calling module.

source
OCPPData.@generate_ocpp_types_from_definitionsMacro
@generate_ocpp_types_from_definitions schema_dir registry_name

Read V201-style OCPP JSON schemas (with definitions + $ref) at macro-expansion time and splice all type definitions into the calling module.

source