| Crates.io | btsnoop_parser |
| lib.rs | btsnoop_parser |
| version | 1.0.0 |
| created_at | 2025-05-03 11:38:06.981598+00 |
| updated_at | 2025-05-03 11:38:06.981598+00 |
| description | Rust parser for the btsnoop format |
| homepage | |
| repository | https://github.com/nullstring/btsnoop_parser |
| max_upload_size | |
| id | 1658727 |
| size | 48,108 |
A Rust library for parsing Bluetooth HCI snoop logs
Explore the docs ยป
Report Bug
ยท
Request Feature
BTSnoop Parser is a Rust library designed for parsing and analyzing Bluetooth HCI (Host Controller Interface) snoop logs. It's particularly useful for debugging and reverse engineering Bluetooth LE communications on Android devices and other platforms that generate btsnoop log files.
โจ Complete Packet Analysis
๐ Comprehensive Protocol Support
๐ Format Support
cargo-ndk recommended for ease of use)[dependencies]
btsnoop_parser = "1.0.0"
or
cargo add btsnoop_parser
```c
2. Build for desktop:
```bash
cargo build --release
For Android:
cargo build --target aarch64-linux-android --release
or
cargo ndk -t arm64-v8a -o /path/to/jniLibs build --release
Note: tests [test_get_test_data, test_parse_btsnoop_file, profile_performance] will fail without a valid btsnoop_hci.log file. This can be ignored
use btsnoop_parser::PacketStream;
let btsnoop_file_path: &str = "btsnoop_hci.log";
let bytes: Vec<u8> = std::fs::read(btsnoop_file_path)?;
let btsnoop_file: BTSnoopFile = parse_btsnoop_file(bytes)?;
println!("Packet 1: {}", btsnoop_file.packets[0]);
For Android: (See BTLeTool for complete example)
In one.nullstring.btsnoop_parser.BTSnoopParser:
public class BTSnoopParser {
static {
System.loadLibrary("btsnoop_parser");
}
private static native String parse(byte[] bytes, boolean write_and_notify_only, boolean sort_by_timestamp);
public static native void log(String text);
public static BTSnoopFile parseBTSnoopFile(byte[] bytes) {
String parsedData = parse(bytes, true, true);
Gson gson = new Gson();
return gson.fromJson(parsedData, BTSnoopFile.class);
}
}
In other class:
BTSnoopFile result = BTSnoopParser.parseBTSnoopFile(bytes);
Contributions are welcome! Here's how you can help:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Distributed under the MIT License. See LICENSE for more information.