diff --git a/btsnoop/bt/hci_acl.py b/btsnoop/bt/hci_acl.py index 39f9cbe..2677757 100644 --- a/btsnoop/bt/hci_acl.py +++ b/btsnoop/bt/hci_acl.py @@ -1,6 +1,7 @@ """ Parse HCI ACL packets """ +import dataclasses import struct import ctypes from ctypes import c_uint @@ -52,6 +53,18 @@ class ACL_HEADER( ctypes.Union ): PB_COMPLETE_L2CAP_PDU : "ACL_PB COMPLETE_L2CAP_PDU" } + +@dataclasses.dataclass +class HciPacketACL: + handle: int + pb: int + bc: int + length: int + data: bytearray + + def __repr__(self): + return f"HciPacketACL(handle={self.handle}, pb={self.pb} ({pb_to_str(self.pb)}, bc={self.bc}, length={self.length}, data={self.data})" + def pb_to_str(pb): """ Return a string representing the packet boundary flag @@ -60,6 +73,7 @@ def pb_to_str(pb): return PB_FLAGS[pb] + def parse(data): """ Parse HCI ACL data @@ -77,4 +91,4 @@ def parse(data): bc = int(hdr.b.bc) length = int(hdr.b.length) # print(f'ACL::{struct.unpack("