# `Meshcore.PacketParser`
[🔗](https://github.com/nyannus/meshcore_ex/blob/v0.1.0/lib/meshcore/packet_parser.ex#L1)

Parser for raw LoRa packets seen in `:rx_log_data` events.

It decodes the packet header and path, parses advertisements, and – when
channel decryption is enabled – recognises and decrypts group-text packets
for channels whose secret is known (learned from `:channel_info` events), so
that a later `:channel_msg_recv` can be annotated with path/RSSI/SNR of the
packet it came from.

This is a pure data structure: every function returns the updated parser.

# `t`

```elixir
@type t() :: %Meshcore.PacketParser{
  channels: %{required(non_neg_integer()) =&gt; map()},
  channels_log: [map()],
  decrypt_channels: boolean()
}
```

# `find_log_channel_msg`

```elixir
@spec find_log_channel_msg(t(), non_neg_integer()) :: map() | nil
```

Finds the most recent logged channel packet carrying text hash `msg_hash`.

# `new`

```elixir
@spec new() :: t()
```

Creates an empty parser.

# `new_channel`

```elixir
@spec new_channel(t(), map()) :: t()
```

Remembers (or replaces) the channel at `chan.channel_idx`.

# `parse_packet_payload`

```elixir
@spec parse_packet_payload(t(), binary(), map()) :: {map(), t()}
```

Parses a raw packet `payload` and merges the findings into `log_data`.

Returns `{log_data, parser}`.

---

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