Copyright 2019, Nordic Semiconductor ASA
Introduction
The Sniffer API is a Python API that allows scripted use of the Nordic Semiconductor
BLE Sniffer. It allows discovery of devices and sniffing of a single device. It provides
access to all the BLE packets received by the sniffer and the devices discovered.
The sniffer consists of four parts as seen in Figure 1. Code that uses the Sniffer API
directly will effectively replace the “Sniffer extcap” and “Wireshark” components.
Figure 1 - The parts of the sniffer.
The “Sniffer extcap” is included under extcap/nrf_sniffer.py (and the helper script
extcap/nrf_sniffer.bat for Windows). See
https://www.wireshark.org/docs/wsdg_html_chunked/ChCaptureExtcap.html for
more information on how the extcap system works. Note: you do not need to use the
extcap if you are using the Sniffer API directly.
Dependencies
The API has been developed using Python 3.7, but should be compatible with any
Python runtime 3.5 and above. It is however not compatible with Python 2. The API
also requires one third party Python library:
1. Pyserial (cross platform) version 3.4 or higher. Download using pip: “pip
install pyserial>=3.4” or use the included “requirements.txt”.
See the Sniffer User Guide for additional information.
Using the Sniffer API
Getting Started
1. Install dependencies.
2. Include the SnifferAPI folder in your Python project.
3. Import the API with
from SnifferAPI import Sniffer
4. Optional: discover a list of the connected sniffers using:
from SnifferAPI import UART
ports = UART.find_sniffer()
5. Instantiate the Sniffer class with e.g
# For firmware < 2.0.0, use baudrate=460800 or omit
baudrate
mySniffer = Sniffer(portnum=”COM40”, baudrate=1000000)
评论0