capture() starts the job, waits for it, downloads the pcap and deletes the box copy. The other methods do one of those steps each.
Handle
Methods
download() and capture() do not need the admin feature.
Types
SnifferOptions
The fields are public to read. Build the value with
SnifferOptions::new() and the builder methods. A struct literal does not compile, so a field added later does not break your code.
SnifferJob
state.is_finished() is true for Done and Failed. A state or an error kind that a newer box sends comes back as Unknown.
SnifferResult
SnifferStatus
SnifferCapture
is_complete() is true when the job state is Done.
Method Reference
capture(options: &SnifferOptions) -> Result<SnifferCapture>
Start a capture job, poll it once a second, download the pcap, and delete the box copy unless keep() is set.
SnifferCapture. When the sniffer stops answering mid-capture, the call still returns the packets recorded before that. Then is_complete() is false, and job.error gives the reason.
Errors:
Error::Box(HTTP 400): an option has the wrong type or is out of range, or two options conflict. The sniffer is not touched.Error::Box(HTTP 409): another capture holds the sniffer.Error::Box(HTTP 502): the sniffer is not on USB, or it did not start. A job that fails later with nothing recorded comes back as HTTP 500.Error::Timeout: the job did not end within 30 s after its duration and astop().
capture() sends stop() and waits 10 s more. When the delete fails, deleted is false and the call still succeeds. The box deletes an old capture after a day.
start(options: &SnifferOptions) -> Result<SnifferJob>
Start a capture job. The call returns when the sniffer records, so a busy, missing or silent sniffer fails here. The crate allows 30 s for the start.
job(job_id: &str) -> Result<SnifferJob>
Report the capture job with this ID. A job exists only in the box HTTP server’s process. After a box restart, the call fails with Error::Box (HTTP 400).
stop() -> Result<SnifferStop>
Stop the running capture early. The capture ends within a fraction of a second, and its pcap keeps the packets recorded until then. Poll job() for the result. SnifferStop has stopped, file and job. stopped is false when no capture that the box API started is in progress.
status() -> Result<SnifferStatus>
Report whether the sniffer is on USB and busy, and its latest capture job. It does not open the sniffer.
download(file: &str) -> Result<Vec<u8>>
Download a capture’s pcap from the Lager Box. Give the path that SnifferJob::file or SnifferResult::file reports. A missing file fails with Error::Box (HTTP 404).
delete(file: &str) -> Result<bool>
Delete a capture’s pcap from the Lager Box. The return value is false when no file was at that path. A path outside the box’s capture folder fails with Error::Box (HTTP 400).
Examples
Follow the DUT while it connects
Stop a capture when the test is done
Notes
- The pcap link type is
NORDIC_BLE(272). Wireshark andtsharkdecode it. - A Lager Box older than 0.65.0 cannot hold a
ble-sniffernet, so a call fails withError::Box(HTTP 404). A box that serves the role listsble-snifferinstatus().capabilities.net_command_roles. - See the CLI reference to flash the dongle and add the net.
- To capture from a script that runs on the Lager Box, see the Python reference.

