예제 #1
0
 def ReadBdAddrCompleteCapture():
     return Capture(lambda packet: b'\x0e\x0a\x01\x09\x10' in packet.event,
       lambda packet: hci_packets.ReadBdAddrCompleteView(
                   hci_packets.CommandCompleteView(
                             hci_packets.EventPacketView(
                                 bt_packets.PacketViewLittleEndian(
                                     list(packet.event))))))
예제 #2
0
 def _is_matching_command_complete(packet_bytes, opcode=None, num_complete=1):
     hci_event = HciMatchers.extract_hci_event_with_code(packet_bytes, EventCode.COMMAND_COMPLETE)
     if hci_event is None:
         return False
     frame = hci_packets.CommandCompleteView(hci_event)
     return (opcode is None or frame.GetCommandOpCode() == opcode) and\
            frame.GetNumHciCommandPackets() == num_complete
예제 #3
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.EventPacketView(
                     bt_packets.PacketViewLittleEndian(list(packet.payload))
                 ))))
예제 #4
0
 def get_address_from_complete(packet):
     packet_bytes = packet.event
     if b'\x0e\x0a\x01\x09\x10' in packet_bytes:
         nonlocal address
         addr_view = hci_packets.ReadBdAddrCompleteView(
             hci_packets.CommandCompleteView(
                 hci_packets.EventPacketView(
                     bt_packets.PacketViewLittleEndian(
                         list(packet_bytes)))))
         address = addr_view.GetBdAddr()
         return True
     return False
예제 #5
0
 def _extract_matching_command_complete(packet_bytes, opcode=None):
     event = HciMatchers._extract_matching_event(packet_bytes,
                                                 EventCode.COMMAND_COMPLETE)
     if event is None:
         return None
     complete = hci_packets.CommandCompleteView(event)
     if opcode is None or complete is None:
         return complete
     else:
         if complete.GetCommandOpCode() != opcode:
             return None
         else:
             return complete