Skip to content

General

To use the Mira Sniffer APIs, link the program against libsniffer.a instead of libmira.a.

The APIs available are mostly the same as MiraOS' APIs, except the networking APIs.

A minimal sniffer firmware starts in the mira_setup function. There it calls mira_sniffer_start to start capturing network packets and it registers a packet capture callback with mira_sniffer_packet_logger_set.

The captured packets can, when they are UDP packets, be decoded with mira_sniffer_udp_payload_get.

Types

mira_sniffer_packet_callback_t

typedef void(* mira_sniffer_packet_callback_t) (mira_sniffer_packet_status_t status, uint8_t header_len, const uint8_t *header, size_t data_len, const uint8_t *data);

Packet reception callback

Enums

mira_sniffer_packet_status_t

Status about received packets

Name Description
MIRA_SNIFFER_STATUS_RX_PKT
MIRA_SNIFFER_STATUS_TX_PKT
MIRA_SNIFFER_STATUS_RX_ACK
MIRA_SNIFFER_STATUS_TX_ACK
MIRA_SNIFFER_STATUS_PKT_TYPE_MASK
MIRA_SNIFFER_STATUS_IS_OK
MIRA_SNIFFER_STATUS_IS_FILTERED
MIRA_SNIFFER_STATUS_IS_DROPPED
MIRA_SNIFFER_STATUS_COLLISION

Structs

mira_sniffer_statistics_t

Network statistics

Name Type Description
listen_no_packet_for_rx int32_t

Functions

mira_sniffer_packet_logger_set

void mira_sniffer_packet_logger_set(mira_sniffer_packet_callback_t callback);

Set packet logger callback.

  • callback the function to call with new packets.

mira_sniffer_start

mira_status_t mira_sniffer_start(uint32_t pan_id, const uint8_t *const encryption_key, uint8_t antenna);

Start sniffing a MiraMesh network.

  • pan_id The PAN ID of the network.

  • encryption_key A 16 bytes encryption key.

  • antenna Which antenna the radio should use.

MIRA_SUCCESS

when started.

MIRA_ERROR_NO_MEMORY

not enough enough memory to start sniffing.

MIRA_ERROR_INVALID_VALUE

failed to set the antenna.

mira_sniffer_restart

mira_status_t mira_sniffer_restart(uint32_t pan_id, const uint8_t *const encryption_key, uint8_t antenna);

Change pan, encryption_key and/or antenna.

  • pan_id The PAN ID of the network.

  • encryption_key A 16 bytes encryption key.

  • antenna Which antenna the radio should use.

MIRA_SUCCESS

when restarted.

MIRA_ERROR_INVALID_VALUE

failed to set the antenna.

mira_sniffer_get_net_state

mira_net_state_t mira_sniffer_get_net_state(void);

Get the current state of network association.

Return value

Name Description
MIRA_NET_STATE_IS_COORDINATOR Node state is coordinator.
MIRA_NET_STATE_NOT_ASSOCIATED Node state is not associated.
MIRA_NET_STATE_ASSOCIATED Node state is associated.
MIRA_NET_STATE_JOINED Node state is joined.

mira_sniffer_get_statistics

mira_status_t mira_sniffer_get_statistics(mira_sniffer_statistics_t *stats);

Get network statistics.

  • stats Pointer to where the statistics is stored.

Return value

Name Description
MIRA_SUCCESS The statistics is stored in stats.
!MIRA_SUCCESS Internal error.
Back to top