示例#1
0
 def _extract_matching_event(packet_bytes, event_code):
     event = hci_packets.EventView(
         bt_packets.PacketViewLittleEndian(list(packet_bytes)))
     if event is None:
         return None
     if event_code is not None and event.GetEventCode() != event_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
示例#3
0
 def LeConnectionCompleteCapture():
     return Capture(
         lambda packet: packet.payload[0] == 0x3e and (packet.payload[2] == 0x01 or packet.payload[2] == 0x0a),
         lambda packet: hci_packets.LeConnectionCompleteView(
             hci_packets.LeMetaEventView(
                 hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))
示例#4
0
 def DisconnectionCompleteCapture():
     return Capture(
         lambda packet: packet.payload[0:2] == b'\x05\x04', lambda packet: hci_packets.DisconnectionCompleteView(
             hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
示例#5
0
 def ConnectionCompleteCapture():
     return Capture(
         lambda packet: packet.payload[0:3] == b'\x03\x0b\x00', lambda packet: hci_packets.ConnectionCompleteView(
             hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
示例#6
0
 def ConnectionRequestCapture():
     return Capture(
         lambda packet: packet.payload[0:2] == b'\x04\x0a', lambda packet: hci_packets.ConnectionRequestView(
             hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
示例#7
0
 def ReadBdAddrCompleteCapture():
     return Capture(
         lambda packet: packet.payload[0:5] == b'\x0e\x0a\x01\x09\x10', lambda packet: hci_packets.ReadBdAddrCompleteView(
             hci_packets.CommandCompleteView(
                 hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))
示例#8
0
 def LogEventCode():
     return lambda event: logging.info(
         "Received event: %x" % hci_packets.EventView(
             bt_packets.PacketViewLittleEndian(list(event.payload))
         ).GetEventCode())