# `ExCEP.Codec.DataAsdu`

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:

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

# `t`

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

# `decode`

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

Decodes a JSON binary into `%DataAsdu{}`.

# `encode`

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

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

# `new`

```elixir
@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`

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

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

# `requires_signature?`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
