def LeConnectionCompleteCapture(): return Capture(lambda packet: packet.event[0] == 0x3e and (packet.event[2] == 0x01 or packet.event[2] == 0x0a), lambda packet: hci_packets.LeConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventPacketView( bt_packets.PacketViewLittleEndian( list(packet.event))))))
def _extract_matching_le_event(packet_bytes, subevent_code): event = hci_packets.LeMetaEventView( HciMatchers._extract_matching_event( packet_bytes, hci_packets.EventCode.LE_META_EVENT)) if event is None: return None if event.GetSubeventCode() != subevent_code: return None return event
def get_handle(packet): packet_bytes = packet.payload nonlocal handle if b'\x3e\x13\x01\x00' in packet_bytes: cc_view = hci_packets.LeConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventView( bt_packets.PacketViewLittleEndian( list(packet_bytes))))) handle = cc_view.GetConnectionHandle() return True if b'\x3e\x13\x0A\x00' in packet_bytes: cc_view = hci_packets.LeEnhancedConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventView( bt_packets.PacketViewLittleEndian( list(packet_bytes))))) handle = cc_view.GetConnectionHandle() return True return False
def payload_handle(packet): packet_bytes = packet.payload if b'\x3e\x13\x01\x00' in packet_bytes: nonlocal conn_handle cc_view = hci_packets.LeConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventPacketView( bt_packets.PacketViewLittleEndian( list(packet_bytes))))) conn_handle = cc_view.GetConnectionHandle() return True return False
def get_handle(packet): packet_bytes = packet.event nonlocal handle nonlocal address if b'\x3e\x13\x01\x00' in packet_bytes: cc_view = hci_packets.LeConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventPacketView( bt_packets.PacketViewLittleEndian( list(packet_bytes))))) handle = cc_view.GetConnectionHandle() address = cc_view.GetPeerAddress() return True if b'\x3e\x13\x0A\x00' in packet_bytes: cc_view = hci_packets.LeEnhancedConnectionCompleteView( hci_packets.LeMetaEventView( hci_packets.EventPacketView( bt_packets.PacketViewLittleEndian( list(packet_bytes))))) handle = cc_view.GetConnectionHandle() address = cc_view.GetPeerResolvablePrivateAddress() return True return False