OSDN Git Service

HciMatchers: Add OOB Related events.
authorMartin Brabham <optedoblivion@google.com>
Fri, 13 Nov 2020 00:39:16 +0000 (16:39 -0800)
committerMartin Brabham <optedoblivion@google.com>
Mon, 16 Nov 2020 18:22:15 +0000 (10:22 -0800)
Additionally, add a useful Logger function that assisted with
solving the problem.

Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: I7d3ccb1593295204d09188f3a0b24b3fbdf3fe14

gd/cert/matchers.py

index edeecf6..ca181cb 100644 (file)
@@ -15,6 +15,8 @@
 #   limitations under the License.
 
 import bluetooth_packets_python3 as bt_packets
+import logging
+
 from bluetooth_packets_python3 import hci_packets
 from bluetooth_packets_python3.hci_packets import EventCode
 from bluetooth_packets_python3 import l2cap_packets
@@ -110,6 +112,10 @@ class HciMatchers(object):
             HciMatchers._extract_matching_le_event(packet_bytes, hci_packets.SubeventCode.ENHANCED_CONNECTION_COMPLETE))
 
     @staticmethod
+    def LogEventCode():
+        return lambda event: logging.info("Received event: %x" % hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(event.event))).GetEventCode())
+
+    @staticmethod
     def LinkKeyRequest():
         return lambda event: HciMatchers.EventWithCode(EventCode.LINK_KEY_REQUEST)
 
@@ -153,6 +159,10 @@ class HciMatchers(object):
     def DisconnectionComplete():
         return lambda event: HciMatchers.EventWithCode(EventCode.DISCONNECTION_COMPLETE)
 
+    @staticmethod
+    def RemoteOobDataRequest():
+        return lambda event: HciMatchers.EventWithCode(EventCode.REMOTE_OOB_DATA_REQUEST)
+
 
 class NeighborMatchers(object):