diff --git a/autopts/ptsprojects/stack/layers/gap.py b/autopts/ptsprojects/stack/layers/gap.py index cc606dfb16..01efaff65a 100644 --- a/autopts/ptsprojects/stack/layers/gap.py +++ b/autopts/ptsprojects/stack/layers/gap.py @@ -95,6 +95,7 @@ def __init__(self, name, manufacturer_data, appearance, svc_data, flags, self.passkey = Property(None) self.conn_params = Property(None) self.pairing_failed_rcvd = Property(None) + self.encryption_failed_rcvd = Property(None) # bond_lost data (addr_type, addr) self.bond_lost_ev_data = Property(None) @@ -224,6 +225,12 @@ def gap_wait_for_pairing_fail(self, timeout=5): return self.pairing_failed_rcvd.data + def gap_wait_for_encryption_fail(self, timeout=5): + if self.encryption_failed_rcvd.data is None: + wait_for_event(timeout, lambda: self.encryption_failed_rcvd.data) + + return self.encryption_failed_rcvd.data + def gap_wait_for_lost_bond(self, timeout=5): if self.bond_lost_ev_data.data is None: wait_for_event(timeout, lambda: self.bond_lost_ev_data.data) diff --git a/autopts/pybtp/btp/gap.py b/autopts/pybtp/btp/gap.py index a00851c20d..6d68b99366 100644 --- a/autopts/pybtp/btp/gap.py +++ b/autopts/pybtp/btp/gap.py @@ -304,6 +304,24 @@ def gap_pairing_failed_ev_(gap, data, data_len): stack.gap.pairing_failed_rcvd.data = (_addr_t, _addr, _reason) +def gap_encryption_failed_ev_(gap, data, data_len): + stack = get_stack() + logging.debug("%s", gap_encryption_failed_ev_.__name__) + + logging.debug("received %r", data) + + fmt = ' + Event parameters: Address_Type (1 octet) + Address (6 octets) + Error (1 octet) + + This event can be sent when IUT encryption procedure fails with + specified error.