Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAP: wait for pairing event #551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

HAP: wait for pairing event #551

wants to merge 1 commit into from

Conversation

wescande
Copy link
Contributor

HAP is supposed to work only when device are bonded.

By listening to the on_pairing event of the connection, we can start add the remote device to the preset_changed_operations_history_per_device only after the bonding (and thus the public address) has been done.

This missing logic was found thanks to https://r.android.com/3236429, an avatar test that try to delete a preset and then wait for the notification / indication to be sent to the device

await self._preset_changed_operation(connection)
# Update the active preset index if needed
await self.notify_active_preset_for_connection(connection)
@connection.on('pairing') # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue here is that this only remembers paired connections when the pairing happens while the service is running. But what about connections from devices that were previously paired and bonded?

Copy link
Contributor Author

@wescande wescande Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that setting up HAS is done before we connect to a remote device.

If an already paired device reconnect, it should go in this if:

            if connection.peer_resolvable_address:
                self.on_incoming_paired_connection(connection)

directly

@zxzxwu
Copy link
Collaborator

zxzxwu commented Sep 11, 2024

My opinion is that Bumble is not designed for persistent usage, so it's better to do this kind of operations at the caller side, which has more (well-controlled) context of persistent states.

@wescande
Copy link
Contributor Author

@zxzxwu, the service need to notify every currently connected devices.
So in parallel of the "persistent usage", has need to know about devices only when paired. Which is the goal of this CL.

The only persistent code in has is to update the device after re connection. I haven't implemented any persistent storage that would works between multiples bumble restart. They are only lasting as long as the current bumble is running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants