ExCEP.Codec.DataAsdu (ex_cep v0.1.1)

Copy Markdown

JSON Data ASDU envelope codec per CSG CEP TS2.2 Section 4.7 (Table 2).

Every management-channel and business-channel ASDU shares the envelope:

{
  "Head": {
    "FunName": "DataRead",
    "NodeId": "GW-001",
    "Cot": "1",
    "Mid": "1001",
    "Timestamp": "2026-11-30 12:00:00.000"
  },
  "Data": { ... }
}

Summary

Functions

Decodes a JSON binary into %DataAsdu{}.

Encodes a %DataAsdu{} to JSON binary using Jason.

Builds a new %DataAsdu{} with auto-populated Mid and Timestamp if omitted.

Builds a response %DataAsdu{} mirroring the request's Mid and NodeId.

Returns true if fun_name is a control/mutation command that should be SM2-signed.

Types

t()

@type t() :: %ExCEP.Codec.DataAsdu{data: map(), head: ExCEP.Codec.DataAsdu.Head.t()}

Functions

decode(json)

@spec decode(binary()) :: {:ok, t()} | {:error, term()}

Decodes a JSON binary into %DataAsdu{}.

encode(data_asdu)

@spec encode(t()) :: {:ok, binary()} | {:error, term()}

Encodes a %DataAsdu{} to JSON binary using Jason.

new(fun_name, node_id, cot \\ :request, data \\ %{}, opts \\ [])

@spec new(String.t(), String.t(), ExCEP.Common.Types.cot(), map(), keyword()) :: t()

Builds a new %DataAsdu{} with auto-populated Mid and Timestamp if omitted.

reply(data_asdu, resp_fun_name, data \\ %{}, opts \\ [])

@spec reply(t(), String.t(), map(), keyword()) :: t()

Builds a response %DataAsdu{} mirroring the request's Mid and NodeId.

requires_signature?(fun_name)

@spec requires_signature?(String.t()) :: boolean()

Returns true if fun_name is a control/mutation command that should be SM2-signed.