Sniffer connector

This module provides a single Sniffer class that supports the following modulations:

  • ASK

  • GFSK

  • BFSK

  • QFSK

  • BPSK

  • QPSK

  • LoRa

This sniffer is configured using a dedicated configuration class, SnifferConfiguration. This class allows users to configure some default fields like the frequency, data rate and synchronization word, but also some packet-specific parameters like the maximum packet size or its endianness:

>>> config = SnifferConfiguration()
>>> config.frequency = 2402000000
>>> config.datarate = 1000000
>>> config.endianness = Endianness.LITTLE
>>> config.packet_size = 200
>>> config.sync_word = b'\xAA\xAA'

Modulation is selected by setting the correct modulation scheme to True:

>>> config.gfsk = True

Some modulations offer extra parameters, like the FSK and LoRa modulations. FSK modulation can be customized through a FSKConfiguration object and LoRa through a LoRaConfiguration object.

Once the sniffer configuration set, sniffing is quite easy:

>>> sniffer = Sniffer(WhadDevice.create("uart0"))
>>> sniffer.configuration = config
>>> sniffer.start()
>>> for packet in sniffer.sniff():
        packet.show()
class whad.phy.connector.sniffer.Sniffer(device)[source]

Phy Sniffer interface for compatible WHAD device.

available_actions(action_filter=None) list[source]

List available actions.

property configuration

Current sniffing configuration

property frequency: int

Configured frequency in Hertz.

on_packet(packet: Packet)[source]

Packet reception handler: put packets in sniffing queue.

Parameters:

packet (Packet) – Received packet

sniff(timeout: float = None) Generator[Packet, None, None][source]

Sniff packets out of thin air.

Parameters:

timeout (float) – Specify the number of seconds after which sniffing will stop. Wait forever if set to None.

Sniffer configuration classes

class whad.phy.sniffing.SnifferConfiguration(frequency: int = 2402000000, little_endian: bool = False, datarate: int = 100000, packet_size: int = 31, sync_word: bytes = b'\xaa', ask: bool = False, gfsk: bool = False, bfsk: bool = False, qfsk: bool = False, bpsk: bool = False, qpsk: bool = False, lora: bool = False, fsk_configuration: FSKConfiguration = None, lora_configuration: LoRaConfiguration = None)[source]

Configuration for sniffing Phy communications.

Parameters:
  • frequency – select the frequency to sniff (f)

  • little_endian – select little endianness (le)

  • datarate – select number of bits per second (d)

  • packet_size – select packet size (s)

  • sync_word – select synchronization word (w)

  • ask – select ASK modulation (ask)

  • gfsk – select GFSK modulation (gfsk)

  • bfsk – select BFSK modulation (bfsk)

  • qfsk – select QFSK modulation (qfsk)

  • bpsk – select BPSK modulation (bpsk)

  • qpsk – select QPSK modulation (qpsk)

  • lora – select LoRa modulation (lora)

class whad.phy.sniffing.FSKConfiguration(deviation: int = 500000)[source]

Configuration for FSK modulation.

Parameters:

deviation – select the modulation deviation (dev)

class whad.phy.sniffing.LoRaConfiguration(spreading_factor: int = 7, coding_rate: int = 45, bandwidth: int = 125000, enable_crc: bool = False, enable_explicit_mode: bool = False, preamble_length: int = 12)[source]

Configuration for LoRa modulation.

Parameters:
  • spreading_factor – select the spreading factor (sf)

  • coding_rate – select the coding rate (cr)

  • bandwidth – select the bandwidth (bw)

  • enable_crc – enable LoRa CRC (crc)

  • enable_explicit_mode – enable LoRa explicit mode (em)

  • preamble_length – set LoRa preamble length in symbols (pl)