Skip to main content
Capture Bluetooth LE radio traffic with a BLE sniffer net. The sniffer is an nRF52840 Dongle that runs Nordic’s nRF Sniffer for Bluetooth LE firmware. A capture runs in the script’s own process and blocks for its full duration.

Import

Methods

Net.get(name, type=NetType.BleSniffer)

capture(duration=10.0, follow=None, address_type=None, follow_by_name=None, only_advertising=False, coded=False, rssi_cut_off=None, out=None)

An attached lager python run ends at 300 s, start-up included, so keep an attached capture under about 280 s and run longer ones detached. The pcap is first written to <out>.part and renamed to out when the capture ends. A capture that fails at the start leaves an existing out unchanged. Returns: a dict with these keys: Raises:
  • ValueError: an option has the wrong type or is out of range, or two options conflict. The sniffer is not touched.
  • BleSnifferBusyError (from lager.protocols.ble_sniffer): another capture holds the sniffer.
  • BleSnifferBackendError (from lager.exceptions): the capture failed. The sniffer is not on USB, another program holds its port, or it did not answer within 2 s. Unplug and replug a sniffer that does not answer. When it stops answering mid-capture, the packets recorded before that stay in out, and the message gives their number.
Under lager python, the default file is in the run’s output folder, so --download brings it back to your computer.

status()

Returns a dict with serial, port (None when the sniffer is not on USB), present and busy. It does not open the sniffer.

Example

A capture longer than 300 seconds needs a detached run: lager python sniff.py --detach.

Notes

  • The pcap link type is NORDIC_BLE (272). Wireshark and tshark decode it.
  • See the CLI reference to flash the dongle and add the net.