Meshcore.PacketParser (Meshcore v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

Creates an empty parser.

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

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

Types

t()

@type t() :: %Meshcore.PacketParser{
  channels: %{required(non_neg_integer()) => map()},
  channels_log: [map()],
  decrypt_channels: boolean()
}

Functions

find_log_channel_msg(packet_parser, msg_hash)

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

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

new()

@spec new() :: t()

Creates an empty parser.

new_channel(p, chan)

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

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

parse_packet_payload(parser, payload, log_data \\ %{})

@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}.