# Btsnoop parser library for Rust
[](https://github.com/mauricelam/btsnoop-rs/actions)
[](https://crates.io/crates/btsnoop)
[](https://docs.rs/btsnoop)
This library provides parsing capaibilities for [btsnoop logs](https://fte.com/webhelpii/bpa600/Content/Technical_Information/BT_Snoop_File_Format.htm).
```toml
[dependencies]
btsnoop = "0.2.1"
```
## Example
```rust
use btsnoop::parse_btsnoop_file;
let btsnoop_bytes: &[u8] = include_bytes!("btsnoop_hci.log");
let file: btsnoop::File = parse_btsnoop_file(btsnoop_bytes).unwrap();
for packet in file.packets {
println!("Packet={:x?}", packet.packet_data);
}
```
## File sources
- `btsnoop` can parse files generated by [Android](https://source.android.com/docs/core/connect/bluetooth/verifying_debugging#debugging-options) and [`btmon`](https://github.com/bluez/bluez/blob/master/monitor/btmon.rst).
- See the subproject `btsnoop-extcap` for a Wireshark extcap plugin that can stream the HCI logs
live from a rooted Android device.
## References
* [Description of the protocol fields](https://fte.com/webhelpii/bpa600/Content/Technical_Information/BT_Snoop_File_Format.htm)
* [Wireshark fields](https://www.wireshark.org/docs/dfref/b/btsnoop.html)
* [Streaming btsnoop logs from Android](https://wejn.org/2021/04/streaming-bluetooth-capture-to-wireshark-without-btsnoop-net/)
* [General resources for BT protocol reverse engineering](https://github.com/Freeyourgadget/Gadgetbridge/wiki/BT-Protocol-Reverse-Engineering)
* [Bluez source code](https://github.com/bluez/bluez/blob/master/src/shared/btsnoop.c)
* [btsnooz - Android script for extracting btsnoop logs from bug reports](https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/tools/scripts/btsnooz.py;drc=0d2319b5fd23ea5054ac3daa517d145dd88ab7d2)