Skip to content

Commit

Permalink
layers/hap: store preset changed events
Browse files Browse the repository at this point in the history
  • Loading branch information
mringwal committed Sep 17, 2024
1 parent fa3ca28 commit 0c23c12
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions autopts/ptsprojects/stack/layers/hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self):
self.event_queues = {
defs.HAP_EV_IAC_DISCOVERY_COMPLETE: [],
defs.HAP_EV_HAUC_DISCOVERY_COMPLETE: [],
defs.HAP_EV_PRESET_CHANGED: [],
}
self.event_handlers = {
defs.HAP_EV_HAUC_DISCOVERY_COMPLETE: self._ev_hauc_discovery_complete,
Expand Down Expand Up @@ -75,3 +76,10 @@ def _ev_hauc_discovery_complete(self, addr_type, addr, status,
peer.hearing_aid_control_point_handle = hearing_aid_control_point_handle
peer.active_preset_index_handle = active_preset_index_handle
peer.discovery_completed = (status == defs.BTP_STATUS_SUCCESS)

def wait_preset_changed_ev(self, addr_type, addr, timeout, change_id, remove=True):
return wait_for_queue_event(
self.event_queues[defs.HAP_EV_PRESET_CHANGED],
lambda _addr_type, _addr, _change_id, *_:
(addr_type, addr, change_id) == (_addr_type, _addr, _change_id),
timeout, remove)

0 comments on commit 0c23c12

Please sign in to comment.